@unisphere/cli 1.58.11 → 2.0.0
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/bundler/package/rollup.js +69 -31
- package/bundler/runtime/rollup.js +2 -163
- package/bundler/shared.js +174 -0
- package/package.json +2 -1
- package/src/lib/commands/how-to/command.js +30 -0
- package/src/lib/commands/how-to/command.js.map +1 -1
- package/src/lib/commands/licenses/command.d.ts +2 -0
- package/src/lib/commands/licenses/command.js +274 -0
- package/src/lib/commands/licenses/command.js.map +1 -0
- package/src/lib/commands/package/build-command.js +31 -0
- package/src/lib/commands/package/build-command.js.map +1 -1
- package/src/lib/commands/package/licenses/command.d.ts +2 -0
- package/src/lib/commands/package/licenses/command.js +12 -0
- package/src/lib/commands/package/licenses/command.js.map +1 -0
- package/src/lib/commands/package/licenses/extract-command.d.ts +2 -0
- package/src/lib/commands/package/licenses/extract-command.js +140 -0
- package/src/lib/commands/package/licenses/extract-command.js.map +1 -0
- package/src/lib/commands/package/package-commands.js +2 -0
- package/src/lib/commands/package/package-commands.js.map +1 -1
- package/src/lib/commands/runtime/build-command.js +39 -0
- package/src/lib/commands/runtime/build-command.js.map +1 -1
- package/src/lib/commands/runtime/command.js +2 -0
- package/src/lib/commands/runtime/command.js.map +1 -1
- package/src/lib/commands/runtime/licenses/command.d.ts +2 -0
- package/src/lib/commands/runtime/licenses/command.js +12 -0
- package/src/lib/commands/runtime/licenses/command.js.map +1 -0
- package/src/lib/commands/runtime/licenses/extract-command.d.ts +2 -0
- package/src/lib/commands/runtime/licenses/extract-command.js +119 -0
- package/src/lib/commands/runtime/licenses/extract-command.js.map +1 -0
- package/src/lib/utils/unisphere/augment-workspace-config.js +13 -11
- package/src/lib/utils/unisphere/augment-workspace-config.js.map +1 -1
- package/src/lib/utils/unisphere/get-dependency-graph.d.ts +4 -2
- package/src/lib/utils/unisphere/get-dependency-graph.js +85 -69
- package/src/lib/utils/unisphere/get-dependency-graph.js.map +1 -1
- package/src/lib/utils/unisphere/get-installed-unisphere-packages.js +1 -0
- package/src/lib/utils/unisphere/get-installed-unisphere-packages.js.map +1 -1
- package/src/lib/utils/unisphere/get-licenses.d.ts +26 -0
- package/src/lib/utils/unisphere/get-licenses.js +128 -0
- package/src/lib/utils/unisphere/get-licenses.js.map +1 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createLicensesCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const debug_1 = require("debug");
|
|
7
|
+
const listr2_1 = require("listr2");
|
|
8
|
+
const utils_1 = require("../../utils/utils");
|
|
9
|
+
const workspace_1 = require("../../utils/unisphere/workspace");
|
|
10
|
+
const defaults_1 = require("../../utils/listr2/defaults");
|
|
11
|
+
const colorette_1 = require("colorette");
|
|
12
|
+
const Table = require("cli-table3");
|
|
13
|
+
const debug = (0, debug_1.default)('unisphere:cli:licenses');
|
|
14
|
+
const createLicensesCommand = () => {
|
|
15
|
+
const command = new commander_1.Command('licenses');
|
|
16
|
+
command
|
|
17
|
+
.description('extract license information for the project dependencies')
|
|
18
|
+
.option('--verbose', 'output debug logs', false)
|
|
19
|
+
.option('--cwd <name>', 'the working directory')
|
|
20
|
+
.hook('preAction', utils_1.printVerboseHook)
|
|
21
|
+
.action((options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const cwd = options.cwd || process.cwd();
|
|
23
|
+
const task = new listr2_1.Listr([
|
|
24
|
+
{
|
|
25
|
+
title: 'Getting workspace',
|
|
26
|
+
task: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
+
const workspace = yield (0, workspace_1.getUnisphereWorkspace)(cwd, {
|
|
28
|
+
suspendRecursion: true,
|
|
29
|
+
});
|
|
30
|
+
if (!workspace) {
|
|
31
|
+
debug(`No .unisphere file found in the directory ${cwd}`);
|
|
32
|
+
throw new Error(`No .unisphere file found in the directory`);
|
|
33
|
+
}
|
|
34
|
+
ctx.workspace = workspace;
|
|
35
|
+
}),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: `Displaying information`,
|
|
39
|
+
task: (ctx, task) => {
|
|
40
|
+
const table = new Table({
|
|
41
|
+
wordWrap: true,
|
|
42
|
+
colWidths: [null, 50, 50],
|
|
43
|
+
head: ['Action', 'Description', 'Command'],
|
|
44
|
+
style: {
|
|
45
|
+
head: ['green', 'bold'],
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
table.push([
|
|
49
|
+
{
|
|
50
|
+
colSpan: 3,
|
|
51
|
+
hAlign: 'center',
|
|
52
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)('Local Environment Commands')),
|
|
53
|
+
},
|
|
54
|
+
]);
|
|
55
|
+
table.push([
|
|
56
|
+
(0, colorette_1.bold)('List projects'),
|
|
57
|
+
'Display list of registered projects in the local environment',
|
|
58
|
+
'npx unisphere local list',
|
|
59
|
+
]);
|
|
60
|
+
table.push([
|
|
61
|
+
(0, colorette_1.bold)('Publish package locally'),
|
|
62
|
+
{
|
|
63
|
+
colSpan: 2,
|
|
64
|
+
hAlign: 'center',
|
|
65
|
+
content: (0, colorette_1.dim)(`To see list of available packages,run command 'npx unisphere local list'
|
|
66
|
+
in the target project directory and then choose the desired package command`),
|
|
67
|
+
},
|
|
68
|
+
]);
|
|
69
|
+
table.push([
|
|
70
|
+
{
|
|
71
|
+
colSpan: 3,
|
|
72
|
+
hAlign: 'center',
|
|
73
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)('Project Commands')),
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
table.push([
|
|
77
|
+
(0, colorette_1.bold)('Init'),
|
|
78
|
+
'Register the project in the local environment (useful for local development)',
|
|
79
|
+
'npx unisphere init',
|
|
80
|
+
]);
|
|
81
|
+
table.push([
|
|
82
|
+
(0, colorette_1.bold)('Info'),
|
|
83
|
+
'Display information about the workspace elements',
|
|
84
|
+
'npx unisphere info',
|
|
85
|
+
]);
|
|
86
|
+
table.push([
|
|
87
|
+
(0, colorette_1.bold)('Check'),
|
|
88
|
+
'Check the workspace elements readiness (Build & Lint)',
|
|
89
|
+
'npx unisphere check',
|
|
90
|
+
]);
|
|
91
|
+
table.push([
|
|
92
|
+
(0, colorette_1.bold)('Reset'),
|
|
93
|
+
'Reset the cache to resolve build issues',
|
|
94
|
+
'npx unisphere reset',
|
|
95
|
+
]);
|
|
96
|
+
let showInitComment = false;
|
|
97
|
+
if (ctx.workspace.config.elements.workspace) {
|
|
98
|
+
table.push([
|
|
99
|
+
{
|
|
100
|
+
colSpan: 3,
|
|
101
|
+
hAlign: 'center',
|
|
102
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)('Workspace Element Commands')),
|
|
103
|
+
},
|
|
104
|
+
]);
|
|
105
|
+
table.push([
|
|
106
|
+
(0, colorette_1.bold)('Build'),
|
|
107
|
+
'Build the workspace',
|
|
108
|
+
'npx unisphere runtime build workspace',
|
|
109
|
+
]);
|
|
110
|
+
table.push([
|
|
111
|
+
(0, colorette_1.bold)('Lint'),
|
|
112
|
+
'Lint the workspace',
|
|
113
|
+
'npx nx run unisphere-workspace:lint --fix',
|
|
114
|
+
]);
|
|
115
|
+
table.push([
|
|
116
|
+
(0, colorette_1.bold)('Serve'),
|
|
117
|
+
'Serve the workspace',
|
|
118
|
+
'npx unisphere runtime serve workspace',
|
|
119
|
+
]);
|
|
120
|
+
table.push([
|
|
121
|
+
(0, colorette_1.bold)('Serve (custom port)'),
|
|
122
|
+
'Serve the workspace with a specific port (e.g. 8080)',
|
|
123
|
+
'npx unisphere runtime serve workspace --port 8080',
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
if (ctx.workspace.config.elements.loader) {
|
|
127
|
+
table.push([
|
|
128
|
+
{
|
|
129
|
+
colSpan: 3,
|
|
130
|
+
hAlign: 'center',
|
|
131
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)('Loader Element Commands')),
|
|
132
|
+
},
|
|
133
|
+
]);
|
|
134
|
+
table.push([
|
|
135
|
+
(0, colorette_1.bold)('Build'),
|
|
136
|
+
'Build the loader',
|
|
137
|
+
'npx unisphere runtime build loader',
|
|
138
|
+
]);
|
|
139
|
+
table.push([
|
|
140
|
+
(0, colorette_1.bold)('Lint'),
|
|
141
|
+
'Lint the loader',
|
|
142
|
+
'npx nx run unisphere-loader:lint --fix',
|
|
143
|
+
]);
|
|
144
|
+
table.push([
|
|
145
|
+
(0, colorette_1.bold)('Serve'),
|
|
146
|
+
'Serve the loader',
|
|
147
|
+
'npx unisphere runtime serve loader',
|
|
148
|
+
]);
|
|
149
|
+
table.push([
|
|
150
|
+
(0, colorette_1.bold)('Serve with port'),
|
|
151
|
+
'Serve the loader with a specific port',
|
|
152
|
+
'npx unisphere runtime serve loader --port 8080',
|
|
153
|
+
]);
|
|
154
|
+
}
|
|
155
|
+
if (Object.keys(ctx.workspace.config.elements.packages || {})
|
|
156
|
+
.length > 0) {
|
|
157
|
+
showInitComment = true;
|
|
158
|
+
for (const [name] of Object.entries(ctx.workspace.config.elements.packages)) {
|
|
159
|
+
table.push([
|
|
160
|
+
{
|
|
161
|
+
colSpan: 3,
|
|
162
|
+
hAlign: 'center',
|
|
163
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)(`Package ${name} Commands`)),
|
|
164
|
+
},
|
|
165
|
+
]);
|
|
166
|
+
table.push([
|
|
167
|
+
(0, colorette_1.bold)('Build'),
|
|
168
|
+
'Build the package',
|
|
169
|
+
`npx unisphere package build ${name}`,
|
|
170
|
+
]);
|
|
171
|
+
table.push([
|
|
172
|
+
(0, colorette_1.bold)('Build with licenses'),
|
|
173
|
+
'Build and extract licenses to dist folder',
|
|
174
|
+
`npx unisphere package build ${name} --licenses`,
|
|
175
|
+
]);
|
|
176
|
+
table.push([
|
|
177
|
+
(0, colorette_1.bold)('Lint'),
|
|
178
|
+
'Lint the package',
|
|
179
|
+
`npx nx run unisphere-package-${name}:lint --fix`,
|
|
180
|
+
]);
|
|
181
|
+
table.push([
|
|
182
|
+
(0, colorette_1.bold)('Extract Licenses'),
|
|
183
|
+
'Extract license information for package dependencies',
|
|
184
|
+
`npx unisphere package licenses extract ${name}`,
|
|
185
|
+
]);
|
|
186
|
+
table.push([
|
|
187
|
+
(0, colorette_1.bold)('Extract Licenses (with options)'),
|
|
188
|
+
'Available flags: --include-transitive, --format=json|summary|all, --output=<path>',
|
|
189
|
+
`npx unisphere package licenses extract ${name} --include-transitive --format=all --output=./licenses`,
|
|
190
|
+
]);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
if (Object.keys(ctx.workspace.config.elements.runtimes || {})
|
|
194
|
+
.length > 0) {
|
|
195
|
+
for (const [name, { distributionChannel, version },] of Object.entries(ctx.workspace.config.elements.runtimes)) {
|
|
196
|
+
table.push([
|
|
197
|
+
{
|
|
198
|
+
colSpan: 3,
|
|
199
|
+
hAlign: 'center',
|
|
200
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)(`Runtime ${name} Commands`)),
|
|
201
|
+
},
|
|
202
|
+
]);
|
|
203
|
+
table.push([
|
|
204
|
+
(0, colorette_1.bold)('Build'),
|
|
205
|
+
'Build the runtime',
|
|
206
|
+
`npx unisphere runtime build ${name}`,
|
|
207
|
+
]);
|
|
208
|
+
table.push([
|
|
209
|
+
(0, colorette_1.bold)('Build with licenses'),
|
|
210
|
+
'Build and extract licenses to dist folder',
|
|
211
|
+
`npx unisphere runtime build ${name} --licenses`,
|
|
212
|
+
]);
|
|
213
|
+
table.push([
|
|
214
|
+
(0, colorette_1.bold)('Serve'),
|
|
215
|
+
'Serve the runtime (default port is 8300)',
|
|
216
|
+
`npx unisphere runtime serve ${name}`,
|
|
217
|
+
]);
|
|
218
|
+
table.push([
|
|
219
|
+
(0, colorette_1.bold)('Serve (custom port)'),
|
|
220
|
+
'Serve the runtime with a specific port (e.g. 8320)',
|
|
221
|
+
`npx unisphere runtime serve ${name} --port 8320`,
|
|
222
|
+
]);
|
|
223
|
+
table.push([
|
|
224
|
+
(0, colorette_1.bold)('Extract Licenses'),
|
|
225
|
+
'Extract license information for runtime dependencies',
|
|
226
|
+
`npx unisphere runtime licenses extract ${name}`,
|
|
227
|
+
]);
|
|
228
|
+
table.push([
|
|
229
|
+
(0, colorette_1.bold)('Extract Licenses (with options)'),
|
|
230
|
+
'Available flags: --include-transitive, --format=json|summary|all, --output=<path>',
|
|
231
|
+
`npx unisphere runtime licenses extract ${name} --include-transitive --format=all --output=./licenses`,
|
|
232
|
+
]);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
if (Object.keys(ctx.workspace.config.elements.applications || {})
|
|
236
|
+
.length > 0) {
|
|
237
|
+
for (const [name, { distributionChannel, version },] of Object.entries(ctx.workspace.config.elements.applications)) {
|
|
238
|
+
table.push([
|
|
239
|
+
{
|
|
240
|
+
colSpan: 3,
|
|
241
|
+
hAlign: 'center',
|
|
242
|
+
content: (0, colorette_1.bold)((0, colorette_1.green)(`Application ${name} Commands`)),
|
|
243
|
+
},
|
|
244
|
+
]);
|
|
245
|
+
table.push([
|
|
246
|
+
(0, colorette_1.bold)('Build'),
|
|
247
|
+
'Build the application',
|
|
248
|
+
`npx unisphere application build ${name}`,
|
|
249
|
+
]);
|
|
250
|
+
table.push([
|
|
251
|
+
(0, colorette_1.bold)('Serve'),
|
|
252
|
+
'Serve the application (default port is 4200)',
|
|
253
|
+
`npx unisphere application serve ${name}`,
|
|
254
|
+
]);
|
|
255
|
+
table.push([
|
|
256
|
+
(0, colorette_1.bold)('Serve (custom port)'),
|
|
257
|
+
'Serve the application with a specific port (e.g. 4400)',
|
|
258
|
+
`npx unisphere application serve ${name} --port 4440`,
|
|
259
|
+
]);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
console.log(table.toString());
|
|
263
|
+
if (showInitComment) {
|
|
264
|
+
console.log(`(*) To see list of available projects, run ${(0, colorette_1.bold)('npx unisphere local projects-list')}`);
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
], (0, defaults_1.getDefaultListrOptions)());
|
|
269
|
+
yield task.run();
|
|
270
|
+
}));
|
|
271
|
+
return command;
|
|
272
|
+
};
|
|
273
|
+
exports.createLicensesCommand = createLicensesCommand;
|
|
274
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/licenses/command.ts"],"names":[],"mappings":";;;;AAAA,yCAAsD;AACtD,iCAA0B;AAC1B,mCAA+B;AAC/B,6CAAqD;AACrD,+DAAwE;AACxE,0DAAqE;AAErE,yCAAkD;AAClD,oCAAoC;AAEpC,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,wBAAwB,CAAC,CAAC;AAGvC,MAAM,qBAAqB,GAAG,GAAY,EAAE;IACjD,MAAM,OAAO,GAAG,IAAI,mBAAO,CAAC,UAAU,CAAC,CAAC;IAExC,OAAO;SACJ,WAAW,CAAC,0DAA0D,CAAC;SACvE,MAAM,CAAC,WAAW,EAAE,mBAAmB,EAAE,KAAK,CAAC;SAC/C,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAAC;SAC/C,IAAI,CAAC,WAAW,EAAE,wBAAgB,CAAC;SACnC,MAAM,CAAC,CAAO,OAAO,EAAE,EAAE;QACxB,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;QAEzC,MAAM,IAAI,GAAG,IAAI,cAAK,CACpB;YACE;gBACE,KAAK,EAAE,mBAAmB;gBAC1B,IAAI,EAAE,CAAO,GAAG,EAAE,EAAE;oBAClB,MAAM,SAAS,GAAG,MAAM,IAAA,iCAAqB,EAAC,GAAG,EAAE;wBACjD,gBAAgB,EAAE,IAAI;qBACvB,CAAC,CAAC;oBAEH,IAAI,CAAC,SAAS,EA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C,YAAY,CAC3C,EAAE,CAAC;4BACF,KAAK,CAAC,IAAI,CAAC;gCACT;oCACE,OAAO,EAAE,CAAC;oCACV,MAAM,EAAE,QAAQ;oCAChB,OAAO,EAAE,IAAA,gBAAI,EAAC,IAAA,iBAAK,EAAC,eAAe,IAAI,WAAW,CAAC,CAAC;iCACrD;6BACF,CAAC,CAAC;4BAEH,KAAK,CAAC,IAAI,CAAC;gCACT,IAAA,gBAAI,EAAC,OAAO,CAAC;gCACb,uBAAuB;gCACvB,mCAAmC,IAAI,EAAE;6BAC1C,CAAC,CAAC;4BAEH,KAAK,CAAC,IAAI,CAAC;gCACT,IAAA,gBAAI,EAAC,OAAO,CAAC;gCACb,8CAA8C;gCAC9C,mCAAmC,IAAI,EAAE;6BAC1C,CAAC,CAAC;4BAEH,KAAK,CAAC,IAAI,CAAC;gCACT,IAAA,gBAAI,EAAC,qBAAqB,CAAC;gCAC3B,wDAAwD;gCACxD,mCAAmC,IAAI,cAAc;6BACtD,CAAC,CAAC;wBACL,CAAC;oBACH,CAAC;oBAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;oBAC9B,IAAI,eAAe,EAAE,CAAC;wBACpB,OAAO,CAAC,GAAG,CACT,8CAA8C,IAAA,gBAAI,EAChD,mCAAmC,CACpC,EAAE,CACJ,CAAC;oBACJ,CAAC;gBACH,CAAC;aACF;SACF,EACD,IAAA,iCAAsB,GAAE,CACzB,CAAC;QAEF,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC,CAAA,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AArUW,QAAA,qBAAqB,yBAqUhC"}
|
|
@@ -5,10 +5,14 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const commander_1 = require("commander");
|
|
6
6
|
const debug_1 = require("debug");
|
|
7
7
|
const listr2_1 = require("listr2");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
8
10
|
const utils_1 = require("../../utils/utils");
|
|
9
11
|
const workspace_1 = require("../../utils/unisphere/workspace");
|
|
10
12
|
const build_unisphere_elements_1 = require("../../utils/unisphere/build-unisphere-elements");
|
|
11
13
|
const defaults_1 = require("../../utils/listr2/defaults");
|
|
14
|
+
const get_licenses_1 = require("../../utils/unisphere/get-licenses");
|
|
15
|
+
//
|
|
12
16
|
const debug = (0, debug_1.default)('unisphere:cli:build');
|
|
13
17
|
const createBuildCommand = (parentCommand) => {
|
|
14
18
|
const command = parentCommand.command('build');
|
|
@@ -21,6 +25,7 @@ const createBuildCommand = (parentCommand) => {
|
|
|
21
25
|
.addArgument(new commander_1.Argument('package', 'the package to build'))
|
|
22
26
|
.option('--cwd <name>', 'the working directory')
|
|
23
27
|
.option('--production', 'build in production mode', false)
|
|
28
|
+
.option('--licenses', 'extract license information after build', false)
|
|
24
29
|
.addOption(noLintOption)
|
|
25
30
|
.hook('preAction', utils_1.printVerboseHook)
|
|
26
31
|
.action((packageName, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -64,6 +69,32 @@ const createBuildCommand = (parentCommand) => {
|
|
|
64
69
|
});
|
|
65
70
|
},
|
|
66
71
|
},
|
|
72
|
+
{
|
|
73
|
+
title: 'Extracting license information',
|
|
74
|
+
skip: () => !options.licenses,
|
|
75
|
+
task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
const packageConfig = ctx.workspace.config.elements.packages[packageName];
|
|
77
|
+
const packagePath = packageConfig.projectPath;
|
|
78
|
+
task.output = `Scanning dependencies...`;
|
|
79
|
+
const result = yield (0, get_licenses_1.getLicenses)(cwd, packagePath, {
|
|
80
|
+
includeTransitive: true,
|
|
81
|
+
});
|
|
82
|
+
const { licenses, missingLicenses } = result;
|
|
83
|
+
// Check for missing licenses and fail the build
|
|
84
|
+
if (missingLicenses.length > 0) {
|
|
85
|
+
const missingList = missingLicenses
|
|
86
|
+
.map(l => ` - ${l.packageName}@${l.version}`)
|
|
87
|
+
.join('\n');
|
|
88
|
+
const errorMessage = `Build failed: Found ${missingLicenses.length} package(s) without license information:\n\n${missingList}\n\nTo see full license details, run:\n npx unisphere package licenses extract ${packageName} --include-transitive`;
|
|
89
|
+
throw new Error(errorMessage);
|
|
90
|
+
}
|
|
91
|
+
// Save to dist folder
|
|
92
|
+
const distPath = path.join(cwd, 'dist', 'unisphere', 'packages', packageName);
|
|
93
|
+
const licensesPath = path.join(distPath, 'licenses.json');
|
|
94
|
+
fs.writeFileSync(licensesPath, (0, get_licenses_1.formatLicensesAsJson)(licenses), 'utf8');
|
|
95
|
+
task.title = `Extracted licenses for ${licenses.length} dependencies to ${path.relative(cwd, licensesPath)}`;
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
67
98
|
], (0, defaults_1.getDefaultListrOptions)());
|
|
68
99
|
yield task.run();
|
|
69
100
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-command.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/package/build-command.ts"],"names":[],"mappings":";;;;AAAA,yCAAsD;AACtD,iCAA0B;AAC1B,mCAA+B;AAC/B,6CAAqD;AACrD,+DAAwE;AACxE,6FAAwG;AACxG,0DAAqE;
|
|
1
|
+
{"version":3,"file":"build-command.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/package/build-command.ts"],"names":[],"mappings":";;;;AAAA,yCAAsD;AACtD,iCAA0B;AAC1B,mCAA+B;AAC/B,yBAAyB;AACzB,6BAA6B;AAC7B,6CAAqD;AACrD,+DAAwE;AACxE,6FAAwG;AACxG,0DAAqE;AAErE,qEAAuF;AAEvF,GAAG;AACH,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,qBAAqB,CAAC,CAAC;AAEpC,MAAM,kBAAkB,GAAG,CAAC,aAAsB,EAAW,EAAE;IACpE,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,OAAO,CA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|
4
|
+
const extract_command_1 = require("./extract-command");
|
|
5
|
+
const createLicensesCommand = (parentCommand) => {
|
|
6
|
+
const licensesCommand = parentCommand.command('licenses');
|
|
7
|
+
licensesCommand.description('manage licenses for Unisphere package dependencies');
|
|
8
|
+
(0, extract_command_1.createExtractCommand)(licensesCommand);
|
|
9
|
+
return licensesCommand;
|
|
10
|
+
};
|
|
11
|
+
exports.createLicensesCommand = createLicensesCommand;
|
|
12
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../../packages/unisphere-cli/src/lib/commands/package/licenses/command.ts"],"names":[],"mappings":";;;AACA,uDAAyD;AAElD,MAAM,qBAAqB,GAAG,CAAC,aAAsB,EAAW,EAAE;IACvE,MAAM,eAAe,GAAG,aAAa,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAE1D,eAAe,CAAC,WAAW,CAAC,oDAAoD,CAAC,CAAC;IAElF,IAAA,sCAAoB,EAAC,eAAe,CAAC,CAAC;IAEtC,OAAO,eAAe,CAAC;AACzB,CAAC,CAAC;AARW,QAAA,qBAAqB,yBAQhC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createExtractCommand = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const commander_1 = require("commander");
|
|
6
|
+
const debug_1 = require("debug");
|
|
7
|
+
const listr2_1 = require("listr2");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const utils_1 = require("../../../utils/utils");
|
|
11
|
+
const workspace_1 = require("../../../utils/unisphere/workspace");
|
|
12
|
+
const defaults_1 = require("../../../utils/listr2/defaults");
|
|
13
|
+
const get_licenses_1 = require("../../../utils/unisphere/get-licenses");
|
|
14
|
+
const debug = (0, debug_1.default)('unisphere:cli:licenses:extract');
|
|
15
|
+
const createExtractCommand = (parentCommand) => {
|
|
16
|
+
const command = parentCommand.command('extract');
|
|
17
|
+
command
|
|
18
|
+
.description('extract license information for package dependencies')
|
|
19
|
+
.option('--verbose', 'output debug logs', false)
|
|
20
|
+
.addArgument(new commander_1.Argument('package', 'the package to extract licenses for'))
|
|
21
|
+
.option('--cwd <name>', 'the working directory')
|
|
22
|
+
.option('--include-transitive', 'include transitive dependencies (default: false)', false)
|
|
23
|
+
.addOption(new commander_1.Option('--format <type>', 'output format')
|
|
24
|
+
.choices(['json', 'summary', 'all'])
|
|
25
|
+
.default('summary'))
|
|
26
|
+
.option('--output <path>', 'output directory (relative path, defaults to ./licenses if format is "all")')
|
|
27
|
+
.hook('preAction', utils_1.printVerboseHook)
|
|
28
|
+
.action((packageName, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
29
|
+
const cwd = options.cwd || process.cwd();
|
|
30
|
+
const task = new listr2_1.Listr([
|
|
31
|
+
{
|
|
32
|
+
title: 'Getting workspace',
|
|
33
|
+
task: (ctx) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const workspace = yield (0, workspace_1.getUnisphereWorkspace)(cwd, {
|
|
35
|
+
suspendRecursion: true,
|
|
36
|
+
});
|
|
37
|
+
if (!workspace) {
|
|
38
|
+
debug(`No .unisphere file found in the directory ${cwd}`);
|
|
39
|
+
throw new Error(`No .unisphere file found in the directory`);
|
|
40
|
+
}
|
|
41
|
+
ctx.workspace = workspace;
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: `Checking package existence`,
|
|
46
|
+
task: (ctx, task) => {
|
|
47
|
+
if (!ctx.workspace.config.elements.packages[packageName]) {
|
|
48
|
+
task.title = `Checking package existence - Package not found`;
|
|
49
|
+
throw new Error(`Package name: ${packageName} not found (did you provide the correct name? run npx unisphere info to list all packages)`);
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
title: `Extracting licenses for package ${packageName}`,
|
|
55
|
+
task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
const packageConfig = ctx.workspace.config.elements.packages[packageName];
|
|
57
|
+
const packagePath = packageConfig.projectPath;
|
|
58
|
+
task.output = `Scanning dependencies...`;
|
|
59
|
+
const result = yield (0, get_licenses_1.getLicenses)(cwd, packagePath, {
|
|
60
|
+
includeTransitive: options.includeTransitive,
|
|
61
|
+
});
|
|
62
|
+
const { licenses, missingLicenses } = result;
|
|
63
|
+
ctx.licenses = licenses;
|
|
64
|
+
const scope = options.includeTransitive ? 'direct and transitive' : 'direct';
|
|
65
|
+
const missingMsg = missingLicenses.length > 0
|
|
66
|
+
? ` (${missingLicenses.length} without license)`
|
|
67
|
+
: '';
|
|
68
|
+
task.title = `Extracted licenses for ${licenses.length} ${scope} dependencies${missingMsg}`;
|
|
69
|
+
}),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: 'Saving results',
|
|
73
|
+
skip: () => !options.output && options.format !== 'all',
|
|
74
|
+
task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
// Default to ./licenses if format is 'all' and no output specified
|
|
76
|
+
const outputPath = path.resolve(cwd, options.output || './licenses');
|
|
77
|
+
// Create output directory if it doesn't exist
|
|
78
|
+
fs.mkdirSync(outputPath, { recursive: true });
|
|
79
|
+
const format = options.format;
|
|
80
|
+
const savedFiles = [];
|
|
81
|
+
if (format === 'all') {
|
|
82
|
+
// Save both JSON and summary
|
|
83
|
+
const jsonFile = path.join(outputPath, `licenses-${packageName}.json`);
|
|
84
|
+
const summaryFile = path.join(outputPath, `licenses-${packageName}.txt`);
|
|
85
|
+
fs.writeFileSync(jsonFile, (0, get_licenses_1.formatLicensesAsJson)(ctx.licenses), 'utf8');
|
|
86
|
+
fs.writeFileSync(summaryFile, (0, get_licenses_1.formatLicensesAsSummary)(ctx.licenses), 'utf8');
|
|
87
|
+
savedFiles.push(path.relative(cwd, jsonFile));
|
|
88
|
+
savedFiles.push(path.relative(cwd, summaryFile));
|
|
89
|
+
task.title = `Saved results to:\n - ${savedFiles.join('\n - ')}`;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
// Save single format
|
|
93
|
+
const extension = format === 'json' ? 'json' : 'txt';
|
|
94
|
+
const filename = `licenses-${packageName}.${extension}`;
|
|
95
|
+
const filePath = path.join(outputPath, filename);
|
|
96
|
+
let content;
|
|
97
|
+
if (format === 'json') {
|
|
98
|
+
content = (0, get_licenses_1.formatLicensesAsJson)(ctx.licenses);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
content = (0, get_licenses_1.formatLicensesAsSummary)(ctx.licenses);
|
|
102
|
+
}
|
|
103
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
104
|
+
task.title = `Saved results to ${path.relative(cwd, filePath)}`;
|
|
105
|
+
}
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
title: 'Displaying results',
|
|
110
|
+
skip: () => !!options.output && options.format !== 'all',
|
|
111
|
+
task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
+
const format = options.format;
|
|
113
|
+
if (format === 'all') {
|
|
114
|
+
// Display both formats when using 'all'
|
|
115
|
+
console.log('\n=== JSON Format ===\n');
|
|
116
|
+
console.log((0, get_licenses_1.formatLicensesAsJson)(ctx.licenses));
|
|
117
|
+
console.log('\n=== Summary Format ===\n');
|
|
118
|
+
console.log((0, get_licenses_1.formatLicensesAsSummary)(ctx.licenses));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
let content;
|
|
122
|
+
if (format === 'json') {
|
|
123
|
+
content = (0, get_licenses_1.formatLicensesAsJson)(ctx.licenses);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
content = (0, get_licenses_1.formatLicensesAsSummary)(ctx.licenses);
|
|
127
|
+
}
|
|
128
|
+
// Output to console
|
|
129
|
+
console.log('\n' + content);
|
|
130
|
+
}
|
|
131
|
+
task.title = 'Results displayed';
|
|
132
|
+
}),
|
|
133
|
+
},
|
|
134
|
+
], (0, defaults_1.getDefaultListrOptions)());
|
|
135
|
+
yield task.run();
|
|
136
|
+
}));
|
|
137
|
+
return command;
|
|
138
|
+
};
|
|
139
|
+
exports.createExtractCommand = createExtractCommand;
|
|
140
|
+
//# sourceMappingURL=extract-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-command.js","sourceRoot":"","sources":["../../../../../../../../packages/unisphere-cli/src/lib/commands/package/licenses/extract-command.ts"],"names":[],"mappings":";;;;AAAA,yCAAsD;AACtD,iCAA0B;AAC1B,mCAA+B;AAC/B,yBAAyB;AACzB,6BAA6B;AAC7B,gDAAwD;AACxD,kEAA2E;AAC3E,6DAAwE;AAExE,wEAK+C;AAE/C,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,gCAAgC,CAAC,CAAC;AAE/C,MAAM,oBAAoB,GAAG,CAAC,aAAsB,EAAW,EAAE;IACtE,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEjD,OAAO;SACJ,WAAW,CAAC,sDAAsD,CAAC;SACnE,MAAM,CAAC,WAAW,EAAE,mBAAmB,EAAE,KAAK,CAAC;SAC/C,WAAW,CAAC,IAAI,oBAAQ,CAAC,SAAS,EAAE,qCAAqC,CAAC,CAAC;SAC3E,MAAM,CAAC,cAAc,EAAE,uBAAuB,CAAC;SAC/C,MAAM,CAAC,sBAAsB,EAAE,kDAAkD,EAAE,KAAK,CAAC;SACzF,SAAS,CACR,IAAI,kBAAM,CAAC,iBAAiB,EAAE,eAAe,CAAC;SAC3C,OAAO,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;SACnC,OAAO,CAAC,SAAS,CAAC,CACtB;SACA,MAAM,CAAC,iBAAiB,EAAE,6EAA6E,CA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zB,CAAC;QAEF,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC,CAAA,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAnJW,QAAA,oBAAoB,wBAmJ/B"}
|
|
@@ -4,11 +4,13 @@ exports.createPackageCommand = void 0;
|
|
|
4
4
|
const commander_1 = require("commander");
|
|
5
5
|
const command_1 = require("./publish/command");
|
|
6
6
|
const build_command_1 = require("./build-command");
|
|
7
|
+
const command_2 = require("./licenses/command");
|
|
7
8
|
const createPackageCommand = () => {
|
|
8
9
|
const packageCommand = new commander_1.Command('package');
|
|
9
10
|
packageCommand.description('manage Unisphere package in the current project');
|
|
10
11
|
(0, build_command_1.createBuildCommand)(packageCommand);
|
|
11
12
|
(0, command_1.createPublishCommand)(packageCommand);
|
|
13
|
+
(0, command_2.createLicensesCommand)(packageCommand);
|
|
12
14
|
return packageCommand;
|
|
13
15
|
};
|
|
14
16
|
exports.createPackageCommand = createPackageCommand;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-commands.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/package/package-commands.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,+CAAyD;AACzD,mDAAqD;
|
|
1
|
+
{"version":3,"file":"package-commands.js","sourceRoot":"","sources":["../../../../../../../packages/unisphere-cli/src/lib/commands/package/package-commands.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,+CAAyD;AACzD,mDAAqD;AACrD,gDAA2D;AAGpD,MAAM,oBAAoB,GAAG,GAAY,EAAE;IAChD,MAAM,cAAc,GAAG,IAAI,mBAAO,CAAC,SAAS,CAAC,CAAC;IAE9C,cAAc,CAAC,WAAW,CAAC,iDAAiD,CAAC,CAAC;IAE9E,IAAA,kCAAkB,EAAC,cAAc,CAAC,CAAC;IACnC,IAAA,8BAAoB,EAAC,cAAc,CAAC,CAAC;IACrC,IAAA,+BAAqB,EAAC,cAAc,CAAC,CAAC;IACtC,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AATW,QAAA,oBAAoB,wBAS/B"}
|
|
@@ -5,10 +5,13 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const commander_1 = require("commander");
|
|
6
6
|
const debug_1 = require("debug");
|
|
7
7
|
const listr2_1 = require("listr2");
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
8
10
|
const utils_1 = require("../../utils/utils");
|
|
9
11
|
const workspace_1 = require("../../utils/unisphere/workspace");
|
|
10
12
|
const build_unisphere_elements_1 = require("../../utils/unisphere/build-unisphere-elements");
|
|
11
13
|
const defaults_1 = require("../../utils/listr2/defaults");
|
|
14
|
+
const get_licenses_1 = require("../../utils/unisphere/get-licenses");
|
|
12
15
|
const debug = (0, debug_1.default)('unisphere:runtime:build');
|
|
13
16
|
const createBuildCommand = (parentCommand) => {
|
|
14
17
|
const command = parentCommand.command('build');
|
|
@@ -21,6 +24,7 @@ const createBuildCommand = (parentCommand) => {
|
|
|
21
24
|
.addArgument(new commander_1.Argument('runtime', 'the runtime to build'))
|
|
22
25
|
.option('--cwd <name>', 'the working directory')
|
|
23
26
|
.option('--production', 'build in production mode', false)
|
|
27
|
+
.option('--licenses', 'extract license information after build', false)
|
|
24
28
|
.addOption(noLintOption)
|
|
25
29
|
.hook('preAction', utils_1.printVerboseHook)
|
|
26
30
|
.action((runtime, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -61,6 +65,41 @@ const createBuildCommand = (parentCommand) => {
|
|
|
61
65
|
});
|
|
62
66
|
},
|
|
63
67
|
},
|
|
68
|
+
{
|
|
69
|
+
title: 'Extracting license information',
|
|
70
|
+
skip: () => !options.licenses,
|
|
71
|
+
task: (ctx, task) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
72
|
+
const runtimeConfig = runtime === 'loader'
|
|
73
|
+
? ctx.workspace.config.elements.loader
|
|
74
|
+
: runtime === 'workspace'
|
|
75
|
+
? ctx.workspace.config.elements.workspace
|
|
76
|
+
: ctx.workspace.config.elements.runtimes[runtime];
|
|
77
|
+
if (!runtimeConfig) {
|
|
78
|
+
throw new Error(`No config found for runtime ${runtime}`);
|
|
79
|
+
}
|
|
80
|
+
const runtimePath = runtimeConfig.projectPath;
|
|
81
|
+
task.output = `Scanning dependencies...`;
|
|
82
|
+
const result = yield (0, get_licenses_1.getLicenses)(cwd, runtimePath, {
|
|
83
|
+
includeTransitive: true,
|
|
84
|
+
});
|
|
85
|
+
const { licenses, missingLicenses } = result;
|
|
86
|
+
// Check for missing licenses and fail the build
|
|
87
|
+
if (missingLicenses.length > 0) {
|
|
88
|
+
const missingList = missingLicenses
|
|
89
|
+
.map(l => ` - ${l.packageName}@${l.version}`)
|
|
90
|
+
.join('\n');
|
|
91
|
+
const errorMessage = `Build failed: Found ${missingLicenses.length} package(s) without license information:\n\n${missingList}\n\nTo see full license details, run:\n npx unisphere runtime licenses extract ${runtime} --include-transitive`;
|
|
92
|
+
throw new Error(errorMessage);
|
|
93
|
+
}
|
|
94
|
+
// Save to dist folder
|
|
95
|
+
const distPath = path.join(cwd, 'dist', 'unisphere', 'runtimes', runtime);
|
|
96
|
+
// Create dist directory if it doesn't exist
|
|
97
|
+
fs.mkdirSync(distPath, { recursive: true });
|
|
98
|
+
const licensesPath = path.join(distPath, 'licenses.json');
|
|
99
|
+
fs.writeFileSync(licensesPath, (0, get_licenses_1.formatLicensesAsJson)(licenses), 'utf8');
|
|
100
|
+
task.title = `Extracted licenses for ${licenses.length} dependencies to ${path.relative(cwd, licensesPath)}`;
|
|
101
|
+
}),
|
|
102
|
+
},
|
|
64
103
|
], (0, defaults_1.getDefaultListrOptions)());
|
|
65
104
|
yield task.run();
|
|
66
105
|
}));
|