@boopkit/cli 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +37 -1
- package/dist/lib/capability.js +15 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,7 +1,42 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
37
|
const commander_1 = require("commander");
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
5
40
|
const status_1 = require("./commands/status");
|
|
6
41
|
const init_1 = require("./commands/init");
|
|
7
42
|
const list_1 = require("./commands/list");
|
|
@@ -9,11 +44,12 @@ const add_1 = require("./commands/add");
|
|
|
9
44
|
const adopt_1 = require("./commands/adopt");
|
|
10
45
|
const update_1 = require("./commands/update");
|
|
11
46
|
const loop_1 = require("./commands/loop");
|
|
47
|
+
const pkgJson = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'));
|
|
12
48
|
const program = new commander_1.Command();
|
|
13
49
|
program
|
|
14
50
|
.name('boop')
|
|
15
51
|
.description('Scaffold new projects from boop profiles and capabilities')
|
|
16
|
-
.version(
|
|
52
|
+
.version(pkgJson.version);
|
|
17
53
|
program
|
|
18
54
|
.command('init')
|
|
19
55
|
.description('Create a new project from a boop profile')
|
package/dist/lib/capability.js
CHANGED
|
@@ -118,15 +118,27 @@ function findPackageDirByCapabilityName(name, searchPaths) {
|
|
|
118
118
|
function listCapabilities() {
|
|
119
119
|
const seen = new Set();
|
|
120
120
|
const capabilities = [];
|
|
121
|
+
// Collect @boopkit dirs to scan: both the CLI package's own node_modules
|
|
122
|
+
// and the current project's node_modules (when run from a boop project)
|
|
123
|
+
const boopkitDirs = [];
|
|
124
|
+
const cliBoopkit = path.join((0, config_1.getBoopRoot)(), 'node_modules', '@boopkit');
|
|
125
|
+
boopkitDirs.push(cliBoopkit);
|
|
126
|
+
const cwdBoopkit = path.join(process.cwd(), 'node_modules', '@boopkit');
|
|
127
|
+
if (cwdBoopkit !== cliBoopkit) {
|
|
128
|
+
boopkitDirs.push(cwdBoopkit);
|
|
129
|
+
}
|
|
121
130
|
// Scan node_modules/@boopkit/cap-* for packages with boopkit.capability === true
|
|
122
|
-
const nodeModulesBoopkit
|
|
123
|
-
|
|
131
|
+
for (const nodeModulesBoopkit of boopkitDirs) {
|
|
132
|
+
if (!fs.existsSync(nodeModulesBoopkit))
|
|
133
|
+
continue;
|
|
124
134
|
const entries = fs.readdirSync(nodeModulesBoopkit, { withFileTypes: true });
|
|
125
135
|
for (const entry of entries) {
|
|
126
136
|
if ((!entry.isDirectory() && !entry.isSymbolicLink()) || !entry.name.startsWith('cap-'))
|
|
127
137
|
continue;
|
|
128
138
|
const capName = entry.name.replace(/^cap-/, '');
|
|
129
|
-
|
|
139
|
+
if (seen.has(capName))
|
|
140
|
+
continue;
|
|
141
|
+
const cap = getCapabilityFromPackage(capName, [process.cwd()]);
|
|
130
142
|
if (cap) {
|
|
131
143
|
seen.add(capName);
|
|
132
144
|
capabilities.push(cap);
|