@digigov/cli 1.0.0-rc.6 → 1.0.1
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/README.md +1 -1
- package/lib.js +68 -60
- package/oclif.manifest.json +1 -1
- package/package.json +10 -12
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ $ npm install -g @digigov/cli
|
|
|
19
19
|
$ digigov COMMAND
|
|
20
20
|
running command...
|
|
21
21
|
$ digigov (-v|--version|version)
|
|
22
|
-
@digigov/cli/1.0.
|
|
22
|
+
@digigov/cli/1.0.1 darwin-arm64 node-v18.19.0
|
|
23
23
|
$ digigov --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ digigov COMMAND
|
package/lib.js
CHANGED
|
@@ -1,25 +1,27 @@
|
|
|
1
|
-
const pkgUp = require(
|
|
2
|
-
const fs = require(
|
|
3
|
-
const path = require(
|
|
4
|
-
const merge = require(
|
|
5
|
-
const execa = require(
|
|
6
|
-
const glob = require(
|
|
7
|
-
const { Command } = require(
|
|
8
|
-
const rushLib = require('@microsoft/rush-lib');
|
|
1
|
+
const pkgUp = require("pkg-up");
|
|
2
|
+
const fs = require("fs-extra");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const merge = require("deepmerge");
|
|
5
|
+
const execa = require("execa");
|
|
6
|
+
const glob = require("glob");
|
|
7
|
+
const { Command } = require("@oclif/command");
|
|
9
8
|
|
|
10
9
|
function resolveProject(dir) {
|
|
11
10
|
const pkg = pkgUp.sync({ cwd: dir || process.cwd() });
|
|
12
11
|
const root = path.dirname(pkg);
|
|
13
12
|
let externalLockFile = false;
|
|
14
|
-
if (
|
|
13
|
+
if (
|
|
14
|
+
fs.existsSync(path.join(root, "yarn.lock")) ||
|
|
15
|
+
fs.existsSync(path.join(root, "package-lock.json"))
|
|
16
|
+
) {
|
|
15
17
|
externalLockFile = true;
|
|
16
18
|
}
|
|
17
|
-
let distDir =
|
|
18
|
-
let src =
|
|
19
|
-
let workspace = {}
|
|
19
|
+
let distDir = "dist";
|
|
20
|
+
let src = "src";
|
|
21
|
+
let workspace = {};
|
|
20
22
|
if (!fs.existsSync(path.join(root, src))) {
|
|
21
|
-
src =
|
|
22
|
-
distDir =
|
|
23
|
+
src = ".";
|
|
24
|
+
distDir = ".";
|
|
23
25
|
}
|
|
24
26
|
// project type heuristics
|
|
25
27
|
let isLib = false;
|
|
@@ -28,24 +30,24 @@ function resolveProject(dir) {
|
|
|
28
30
|
let isDocs = false;
|
|
29
31
|
|
|
30
32
|
if (
|
|
31
|
-
fs.existsSync(path.join(root,
|
|
32
|
-
fs.existsSync(path.join(root,
|
|
33
|
+
fs.existsSync(path.join(root, "next.config.js")) ||
|
|
34
|
+
fs.existsSync(path.join(root, "pages"))
|
|
33
35
|
) {
|
|
34
36
|
isApp = true;
|
|
35
37
|
}
|
|
36
38
|
if (
|
|
37
|
-
fs.existsSync(path.join(root,
|
|
38
|
-
fs.existsSync(path.join(root,
|
|
39
|
+
fs.existsSync(path.join(root, "docusaurus.config.js")) &&
|
|
40
|
+
fs.existsSync(path.join(root, "docs"))
|
|
39
41
|
) {
|
|
40
42
|
isDocs = true;
|
|
41
43
|
}
|
|
42
|
-
if (fs.existsSync(path.join(root,
|
|
44
|
+
if (fs.existsSync(path.join(root, "src")) && !isApp) {
|
|
43
45
|
isLib = true;
|
|
44
46
|
}
|
|
45
47
|
|
|
46
48
|
const rush = resolveWorkspace();
|
|
47
49
|
if (rush) {
|
|
48
|
-
isWorkspace = true
|
|
50
|
+
isWorkspace = true;
|
|
49
51
|
workspace = {
|
|
50
52
|
config: rush,
|
|
51
53
|
root: rush.rushJsonFolder,
|
|
@@ -54,9 +56,9 @@ function resolveProject(dir) {
|
|
|
54
56
|
|
|
55
57
|
const isNodeLib = !isLib && !isApp && !isWorkspace && !isDocs;
|
|
56
58
|
|
|
57
|
-
let ignore = path.resolve(root,
|
|
59
|
+
let ignore = path.resolve(root, ".gitignore");
|
|
58
60
|
if (!fs.existsSync(ignore) && workspace.root) {
|
|
59
|
-
ignore = path.resolve(workspace.root,
|
|
61
|
+
ignore = path.resolve(workspace.root, ".gitignore");
|
|
60
62
|
}
|
|
61
63
|
|
|
62
64
|
if (!fs.existsSync(ignore)) {
|
|
@@ -64,11 +66,11 @@ function resolveProject(dir) {
|
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
let digigov = {};
|
|
67
|
-
if (fs.existsSync(path.join(root,
|
|
68
|
-
digigov = require(path.join(root,
|
|
69
|
+
if (fs.existsSync(path.join(root, "digigovrc.json"))) {
|
|
70
|
+
digigov = require(path.join(root, "digigovrc.json"));
|
|
69
71
|
}
|
|
70
|
-
if (fs.existsSync(path.join(root,
|
|
71
|
-
digigov = require(path.join(root,
|
|
72
|
+
if (fs.existsSync(path.join(root, "digigovrc.js"))) {
|
|
73
|
+
digigov = require(path.join(root, "digigovrc.js"));
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
const packageJS = require(pkg);
|
|
@@ -76,12 +78,12 @@ function resolveProject(dir) {
|
|
|
76
78
|
const devDependencies = packageJS.devDependencies || {};
|
|
77
79
|
const dependencies = packageJS.dependencies || {};
|
|
78
80
|
const peerDependencies = packageJS.peerDependencies || {};
|
|
79
|
-
const isTs = Object.keys(devDependencies).includes(
|
|
81
|
+
const isTs = Object.keys(devDependencies).includes("typescript");
|
|
80
82
|
const allDependencies = {
|
|
81
83
|
...dependencies,
|
|
82
84
|
...devDependencies,
|
|
83
85
|
...peerDependencies,
|
|
84
|
-
}
|
|
86
|
+
};
|
|
85
87
|
// hook applies extra properties based on project type
|
|
86
88
|
return {
|
|
87
89
|
name: packageJS.name,
|
|
@@ -114,12 +116,12 @@ function localRequire(file, dflt) {
|
|
|
114
116
|
|
|
115
117
|
function makeConfig(file, cfg) {
|
|
116
118
|
let hook = {};
|
|
117
|
-
if (file && typeof file !==
|
|
119
|
+
if (file && typeof file !== "string") {
|
|
118
120
|
hook = file;
|
|
119
|
-
} else if (typeof file ===
|
|
121
|
+
} else if (typeof file === "string") {
|
|
120
122
|
hook = localRequire(file, {});
|
|
121
123
|
}
|
|
122
|
-
if (typeof hook ===
|
|
124
|
+
if (typeof hook === "function") {
|
|
123
125
|
return hook(cfg);
|
|
124
126
|
}
|
|
125
127
|
if (hook) {
|
|
@@ -129,11 +131,13 @@ function makeConfig(file, cfg) {
|
|
|
129
131
|
|
|
130
132
|
function resolveWorkspace(dir) {
|
|
131
133
|
try {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
const rushLib = require("@microsoft/rush-lib");
|
|
135
|
+
const rushConfiguration = rushLib.RushConfiguration.loadFromDefaultLocation(
|
|
136
|
+
{
|
|
137
|
+
startingFolder: process.cwd(),
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
return rushConfiguration;
|
|
137
141
|
} catch (err) {
|
|
138
142
|
// console.log(err);
|
|
139
143
|
}
|
|
@@ -144,18 +148,17 @@ Identify if project running the command from, is lerna-enabled. If so, return
|
|
|
144
148
|
lerna registered projects metadata.
|
|
145
149
|
*/
|
|
146
150
|
function resolveLocalPackages(dir, dependencies) {
|
|
147
|
-
const packages = {}
|
|
151
|
+
const packages = {};
|
|
148
152
|
const rush = resolveWorkspace(dir);
|
|
149
153
|
if (rush) {
|
|
150
|
-
rush.projects.forEach(p => {
|
|
154
|
+
rush.projects.forEach((p) => {
|
|
151
155
|
if (dependencies.includes(p.packageName)) {
|
|
152
|
-
packages[p.packageName] = resolveProject(p.projectFolder)
|
|
156
|
+
packages[p.packageName] = resolveProject(p.projectFolder);
|
|
153
157
|
}
|
|
154
|
-
})
|
|
155
|
-
return packages
|
|
158
|
+
});
|
|
159
|
+
return packages;
|
|
156
160
|
}
|
|
157
161
|
return {};
|
|
158
|
-
|
|
159
162
|
}
|
|
160
163
|
|
|
161
164
|
/**
|
|
@@ -166,7 +169,7 @@ function resolveLocalPackages(dir, dependencies) {
|
|
|
166
169
|
function aliases(dir, absolute = false) {
|
|
167
170
|
const aliases = {};
|
|
168
171
|
const project = resolveProject(dir);
|
|
169
|
-
const depKeys = [
|
|
172
|
+
const depKeys = ["dependencies", "peerDependencies", "devDependencies"];
|
|
170
173
|
const root = project.root;
|
|
171
174
|
const deps = depKeys.reduce((deps, key) => {
|
|
172
175
|
return deps.concat(Object.keys(project.package[key] || {}));
|
|
@@ -174,7 +177,12 @@ function aliases(dir, absolute = false) {
|
|
|
174
177
|
const packages = resolveLocalPackages(project.root, deps);
|
|
175
178
|
Object.keys(packages).forEach((key) => {
|
|
176
179
|
const project = packages[key];
|
|
177
|
-
if (
|
|
180
|
+
if (
|
|
181
|
+
deps.includes(project.name) &&
|
|
182
|
+
project.package.devDependencies &&
|
|
183
|
+
project.package.devDependencies["@digigov/cli-build"] &&
|
|
184
|
+
project.isWorkspace
|
|
185
|
+
) {
|
|
178
186
|
const projectSrc = path.join(project.root, project.src);
|
|
179
187
|
if (absolute) {
|
|
180
188
|
aliases[project.name] = path.resolve(root, projectSrc);
|
|
@@ -213,27 +221,27 @@ const extractCommandArgs = (config, commandArgs) => {
|
|
|
213
221
|
}
|
|
214
222
|
}
|
|
215
223
|
});
|
|
216
|
-
return vars
|
|
217
|
-
}
|
|
224
|
+
return vars;
|
|
225
|
+
};
|
|
218
226
|
|
|
219
227
|
class DigigovCommand extends Command {
|
|
220
228
|
async exec(script, args, config) {
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
throw new Error(`Executable ${script} not installed`)
|
|
229
|
+
const binLocation = [process.cwd(), this.dirname, __dirname].find(
|
|
230
|
+
(location) => {
|
|
231
|
+
return fs.existsSync(
|
|
232
|
+
path.join(location, "node_modules", ".bin", script),
|
|
233
|
+
);
|
|
234
|
+
},
|
|
235
|
+
);
|
|
236
|
+
if (!binLocation || !fs.existsSync(binLocation)) {
|
|
237
|
+
throw new Error(`Executable ${script} not installed`);
|
|
231
238
|
}
|
|
232
|
-
|
|
239
|
+
let executable = path.join(binLocation, "node_modules", ".bin", script);
|
|
240
|
+
console.log("Running ", executable, ...args);
|
|
233
241
|
try {
|
|
234
|
-
return await execa(executable, args, { ...config, stdio:
|
|
242
|
+
return await execa(executable, args, { ...config, stdio: "inherit" });
|
|
235
243
|
} catch (err) {
|
|
236
|
-
process.exit(err.exitCode)
|
|
244
|
+
process.exit(err.exitCode);
|
|
237
245
|
}
|
|
238
246
|
}
|
|
239
247
|
}
|
|
@@ -244,5 +252,5 @@ module.exports = {
|
|
|
244
252
|
DigigovCommand,
|
|
245
253
|
resolveProject,
|
|
246
254
|
resolveWorkspace,
|
|
247
|
-
extractCommandArgs
|
|
255
|
+
extractCommandArgs,
|
|
248
256
|
};
|
package/oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"1.0.
|
|
1
|
+
{"version":"1.0.1","commands":{"hello":{"id":"hello","description":"describe the command here","pluginName":"@digigov/cli","pluginType":"core","aliases":[],"examples":["$ digigov hello\nhello world from ./src/hello.ts!\n"],"flags":{},"args":[{"name":"file"}]}}}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digigov/cli",
|
|
3
3
|
"description": "CLI for Digigov apps and libs with plugin support",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"author": "GRNET Devs <devs@lists.grnet.gr>",
|
|
6
6
|
"bin": {
|
|
7
7
|
"digigov": "./bin/run"
|
|
@@ -10,16 +10,15 @@
|
|
|
10
10
|
"@oclif/command": "1.8.0",
|
|
11
11
|
"@oclif/config": "1",
|
|
12
12
|
"@oclif/plugin-help": "3",
|
|
13
|
-
"tslib": "2.
|
|
13
|
+
"tslib": "2.6.2",
|
|
14
14
|
"cli-ux": "5.5.1",
|
|
15
15
|
"@oclif/errors": "1.3.4",
|
|
16
16
|
"pkg-up": "3.1.0",
|
|
17
|
-
"fs-extra": "
|
|
17
|
+
"fs-extra": "11.2.0",
|
|
18
18
|
"deepmerge": "4.2.2",
|
|
19
19
|
"execa": "5.0.0",
|
|
20
20
|
"rimraf": "3.0.2",
|
|
21
21
|
"glob": "7.1.6",
|
|
22
|
-
"@microsoft/rush-lib": "5.83.3",
|
|
23
22
|
"publint": "0.1.8"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
@@ -27,14 +26,15 @@
|
|
|
27
26
|
"@oclif/test": "1",
|
|
28
27
|
"@types/chai": "4",
|
|
29
28
|
"@types/mocha": "5",
|
|
30
|
-
"@types/node": "
|
|
29
|
+
"@types/node": "18.19.0",
|
|
31
30
|
"chai": "4",
|
|
32
31
|
"globby": "11.0.0",
|
|
33
32
|
"mocha": "5",
|
|
34
33
|
"nyc": "14",
|
|
35
|
-
"ts-node": "
|
|
34
|
+
"ts-node": "10.9.2",
|
|
36
35
|
"typescript": "4.9.5",
|
|
37
|
-
"publint": "0.1.8"
|
|
36
|
+
"publint": "0.1.8",
|
|
37
|
+
"@microsoft/rush-lib": "5.112.2"
|
|
38
38
|
},
|
|
39
39
|
"engines": {
|
|
40
40
|
"node": ">=12.13.0"
|
|
@@ -61,15 +61,13 @@
|
|
|
61
61
|
"init": "./lib/hooks/init/addcommand"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
+
"types": "lib/index.d.ts",
|
|
64
65
|
"scripts": {
|
|
65
66
|
"publint": "publint",
|
|
66
67
|
"lint": "echo 'no lint needed (yet)'",
|
|
67
|
-
"postpack": "rm -f oclif.manifest.json",
|
|
68
|
-
"prepack": "oclif-dev manifest && oclif-dev readme",
|
|
69
68
|
"prepublish": "tsc",
|
|
70
69
|
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
|
71
70
|
"version": "oclif-dev readme && git add README.md",
|
|
72
71
|
"build": "tsc"
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
}
|
|
72
|
+
}
|
|
73
|
+
}
|