Skip to content

Commit 8a5d1ea

Browse files
committed
Add jsnpm, ignore alpha packages from index, add individual test script
1 parent 181ff44 commit 8a5d1ea

23 files changed

+177
-18
lines changed

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# mono [![](https://circleci.com/gh/omrilotan/mono.svg?style=svg)](https://circleci.com/gh/omrilotan/workflows/mono)
2-
## A "mono-repo" for several packages
2+
A "mono-repo" for several packages
33

44
## TOC
55

@@ -10,8 +10,9 @@
1010
| **`boxt`** | [Create boxes around text](./packages/boxt#readme) | [![](https://img.shields.io/npm/v/boxt.svg)](https://www.npmjs.com/package/boxt)
1111
| **`edit-package`** | [Read, write and reset package.json](./packages/edit-package#readme) | [![](https://img.shields.io/npm/v/edit-package.svg)](https://www.npmjs.com/package/edit-package)
1212
| **`@(._.)/execute`** | [Executes script in a child process](./packages/execute#readme) | [![](https://img.shields.io/npm/v/%40\(._.\)/execute.svg)](https://www.npmjs.com/package/%40\(._.\)/execute)
13+
| <sup>[WIP]</sup> **`jsnpm`** | [NPM API for application workflow](./packages/jsnpm#readme) | [![](https://img.shields.io/npm/v/jsnpm.svg)](https://www.npmjs.com/package/jsnpm)
1314
| **`markt`** | [Generate pages from markdown](./packages/markt#readme) | [![](https://img.shields.io/npm/v/markt.svg)](https://www.npmjs.com/package/markt)
1415
| **`oh-my-gauge`** | [Gauge and Benchmark - time Javascript operations](./packages/oh-my-gauge#readme) | [![](https://img.shields.io/npm/v/oh-my-gauge.svg)](https://www.npmjs.com/package/oh-my-gauge)
1516
| **`paraphrase`** | [Create flavoured string phraser](./packages/paraphrase#readme) | [![](https://img.shields.io/npm/v/paraphrase.svg)](https://www.npmjs.com/package/paraphrase)
16-
| **`twinsies`** | [Pluggable file copier](./packages/twinsies#readme) | [![](https://img.shields.io/npm/v/twinsies.svg)](https://www.npmjs.com/package/twinsies)
17+
| <sup>[WIP]</sup> **`twinsies`** | [Pluggable file copier](./packages/twinsies#readme) | [![](https://img.shields.io/npm/v/twinsies.svg)](https://www.npmjs.com/package/twinsies)
1718
| **`upgradable`** | [Interactive upgrade machine for NPM CLI tools](./packages/upgradable#readme) | [![](https://img.shields.io/npm/v/upgradable.svg)](https://www.npmjs.com/package/upgradable)

packages/assign/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
"url": "git+https://github.com/omrilotan/mono.git"
1010
},
1111
"homepage": "https://omrilotan.github.io/mono/assign/",
12-
"main": "index.js"
12+
"main": "index.js",
13+
"scripts": {
14+
"test": "cd ../../; npm t assign; cd -"
15+
}
1316
}

packages/bench-press/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
},
1111
"homepage": "https://omrilotan.github.io/mono/bench-press/",
1212
"main": "index.js",
13+
"scripts": {
14+
"test": "cd ../../; npm t bench-press; cd -"
15+
},
1316
"dependencies": {
1417
"paraphrase": "^1.2.1"
1518
}

packages/boxt/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"homepage": "https://omrilotan.github.io/mono/boxt/",
1212
"main": "index.js",
1313
"scripts": {
14-
"start": "node examples"
14+
"start": "node examples",
15+
"test": "cd ../../; npm t boxt; cd -"
1516
},
1617
"dependencies": {
1718
"colors": "^1.3.0"

packages/edit-package/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
},
1111
"homepage": "https://omrilotan.github.io/mono/edit-package/",
1212
"main": "index.js",
13+
"scripts": {
14+
"test": "cd ../../; npm t edit-package; cd -"
15+
},
1316
"dependencies": {
1417
"lodash.merge": "^4.6.1"
1518
},

packages/execute/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
"type": "git",
1010
"url": "git+https://github.com/omrilotan/mono.git"
1111
},
12-
"main": "index.js"
12+
"main": "index.js",
13+
"scripts": {
14+
"test": "cd ../../; npm t execute; cd -"
15+
}
1316
}

packages/jsnpm/.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.*
2+
*.log
3+
spec.js

packages/jsnpm/.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

packages/jsnpm/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# [WIP] jsnpm [![](https://img.shields.io/npm/v/jsnpm.svg)](https://www.npmjs.com/package/jsnpm) [![](https://img.shields.io/badge/mono--000000.svg?logo=github&style=social)](https://github.com/omrilotan/mono)
2+
3+
NPM API for application workflow (WIP)

packages/jsnpm/index.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
const _exists = require('./lib/exists');
2+
3+
let instance;
4+
5+
function npm() {
6+
return new Promise((resolve, reject) => {
7+
if (instance && instance.constructor.name === 'EventEmitter') {
8+
resolve(instance);
9+
}
10+
11+
require('npm').load((error, instance) => {
12+
if (error) {
13+
reject(error);
14+
return;
15+
}
16+
17+
resolve(instance);
18+
});
19+
});
20+
}
21+
22+
function exists(name) {
23+
return new Promise(resolve =>npm()
24+
.then(instance => _exists.call(instance, name))
25+
.then(result => resolve(result))
26+
.catch(error => {
27+
throw error;
28+
}));
29+
}
30+
31+
module.exports = {
32+
exists,
33+
};

packages/jsnpm/lib/exists.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = function exists(module) {
2+
return new Promise((resolve, reject) => {
3+
if (this.constructor.name !== 'EventEmitter') {
4+
const error = new TypeError(`'exists' must be call on an NPM instance (EventEmitter), was called on ${this.constructor.name}`);
5+
reject(error);
6+
return;
7+
}
8+
9+
this.view(module, 'name', error => resolve(!error));
10+
});
11+
};

packages/jsnpm/lib/publish.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = function publish() {
2+
return new Promise((resolve, reject) => {
3+
if (this.constructor.name !== 'EventEmitter') {
4+
const error = new TypeError(`'publish' must be call on an NPM instance (EventEmitter), was called on ${this.constructor.name}`);
5+
reject(error);
6+
return;
7+
}
8+
9+
this.publish(error => error ? reject(error) : resolve());
10+
});
11+
};

packages/jsnpm/lib/set-tag.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = function setTag(module, tag) {
2+
return new Promise((resolve, reject) => {
3+
if (this.constructor.name !== 'EventEmitter') {
4+
const error = new TypeError(`'setTag' must be call on an NPM instance (EventEmitter), was called on ${this.constructor.name}`);
5+
reject(error);
6+
return;
7+
}
8+
9+
this.distTag('set', module, tag, error => error ? reject(error) : resolve());
10+
});
11+
};

packages/jsnpm/lib/view-version.js

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module.exports = function viewVersion(module) {
2+
return new Promise((resolve, reject) => {
3+
if (this.constructor.name !== 'EventEmitter') {
4+
const error = new TypeError(`'viewVersion' must be call on an NPM instance (EventEmitter), was called on ${this.constructor.name}`);
5+
reject(error);
6+
return;
7+
}
8+
9+
this.view(module, 'version', (error, result) => {
10+
if (error) {
11+
reject(error);
12+
13+
return;
14+
}
15+
16+
if (!Object.keys(result).length) {
17+
resolve(null);
18+
19+
return;
20+
}
21+
22+
resolve(result[Object.keys(result)[0]].version);
23+
});
24+
});
25+
};

packages/jsnpm/package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "jsnpm",
3+
"version": "0.1.0-alpha.1",
4+
"description": "Use NPM in Javascript runtime",
5+
"author": "omrilotan",
6+
"license": "MIT",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/omrilotan/mono.git"
10+
},
11+
"homepage": "https://omrilotan.github.io/mono/jsnpm/",
12+
"main": "index.js",
13+
"scripts": {
14+
"test": "cd ../../; npm t jsnpm; cd -"
15+
},
16+
"dependencies": {
17+
"npm": "^5.6.0"
18+
}
19+
}

packages/jsnpm/spec.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const jsnpm = require('./');
2+
3+
describe('jsnpm', async() => {
4+
it('wip', async() => {
5+
const exists = await jsnpm.exists('jsnpm');
6+
7+
assert(exists, 'jsnpm package does not exist');
8+
});
9+
it('wip', async() => {
10+
const exists = await jsnpm.exists('ljaslkjasdnkldjas-09u2398u23uhe');
11+
12+
assert(!exists, 'ljaslkjasdnkldjas-09u2398u23uhe package exists');
13+
});
14+
});
15+

packages/markt/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
"markt": "./bin/markt"
1414
},
1515
"main": "index.js",
16+
"scripts": {
17+
"test": "cd ../../; npm t markt; cd -"
18+
},
1619
"dependencies": {
1720
"fs-extra": "^5.0.0",
1821
"marked": "^0.3.19",

packages/oh-my-gauge/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
"url": "git+https://github.com/omrilotan/oh-my-gauge.git"
1010
},
1111
"homepage": "https://omrilotan.github.io/mono/oh-my-gauge/",
12-
"main": "index.js"
12+
"main": "index.js",
13+
"scripts": {
14+
"test": "cd ../../; npm t oh-my-gauge; cd -"
15+
}
1316
}

packages/paraphrase/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@
99
"url": "git+https://github.com/omrilotan/mono.git"
1010
},
1111
"homepage": "https://omrilotan.github.io/mono/paraphrase/",
12-
"main": "index.js"
12+
"main": "index.js",
13+
"scripts": {
14+
"test": "cd ../../; npm t paraphrase; cd -"
15+
}
1316
}

packages/twinsies/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Twinsies [![](https://img.shields.io/npm/v/twinsies.svg)](https://www.npmjs.com/package/twinsies) [![](https://img.shields.io/badge/mono--000000.svg?logo=github&style=social)](https://github.com/omrilotan/mono)
1+
# [WIP] Twinsies [![](https://img.shields.io/npm/v/twinsies.svg)](https://www.npmjs.com/package/twinsies) [![](https://img.shields.io/badge/mono--000000.svg?logo=github&style=social)](https://github.com/omrilotan/mono)
22

3-
Pluggable file copier. WIP
3+
Pluggable file copier
44

55
```js
66
const Twinsies = require('twinsies')

packages/twinsies/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
},
1111
"homepage": "https://omrilotan.github.io/mono/twinsies/",
1212
"main": "index.js",
13+
"scripts": {
14+
"test": "cd ../../; npm t twinsies; cd -"
15+
},
1316
"dependencies": {
1417
"fs-readfile-promise": "^3.0.0",
1518
"output-file": "^1.1.1",

packages/upgradable/package.json

+6-9
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,20 @@
88
"type": "git",
99
"url": "git+https://github.com/omrilotan/mono.git"
1010
},
11-
"main": "lib/start/index.js",
12-
"scripts": {
13-
"start": "./index.js"
14-
},
11+
"homepage": "https://omrilotan.github.io/mono/upgradable/",
1512
"bin": {
1613
"upgradable": "./index.js"
1714
},
18-
"publishConfig": {
19-
"tag": "latest",
20-
"tag-version-prefix": ""
15+
"main": "lib/start/index.js",
16+
"scripts": {
17+
"start": "./index.js",
18+
"test": "cd ../../; npm t upgradable; cd -"
2119
},
2220
"dependencies": {
2321
"boxt": "^0.3.0",
2422
"colors": "^1.1.2",
2523
"npm": "^5.7.1",
2624
"prompt-confirm": "^1.2.0",
2725
"semver": "^5.5.0"
28-
},
29-
"devDependencies": {}
26+
}
3027
}

scripts/homepage.js

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ const title = 'mono';
1717
version,
1818
} = require(`../packages/${item}/package.json`);
1919

20+
if (version.includes('alpha')) {
21+
return;
22+
}
23+
2024
const link = `./${item}/`;
2125

2226
rows.push(`

0 commit comments

Comments
 (0)