piral-cli 0.15.0-alpha.4122 → 0.15.0-alpha.4284
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 +7 -5
- package/lib/apps/debug-pilet.js +28 -42
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +20 -34
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/new-pilet.js +5 -9
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.js +9 -3
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/publish-pilet.d.ts +4 -0
- package/lib/apps/publish-pilet.js +4 -3
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.d.ts +4 -0
- package/lib/apps/publish-piral.js +9 -7
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/apps/upgrade-pilet.js +2 -8
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/apps/upgrade-piral.js +1 -1
- package/lib/apps/upgrade-piral.js.map +1 -1
- package/lib/bundler.js +1 -1
- package/lib/bundler.js.map +1 -1
- package/lib/commands.js +14 -6
- package/lib/commands.js.map +1 -1
- package/lib/common/browser.d.ts +1 -0
- package/lib/common/browser.js +16 -10
- package/lib/common/browser.js.map +1 -1
- package/lib/common/clients/index.d.ts +19 -0
- package/lib/common/clients/index.js +40 -0
- package/lib/common/clients/index.js.map +1 -0
- package/lib/common/clients/lerna.d.ts +6 -1
- package/lib/common/clients/lerna.js +67 -3
- package/lib/common/clients/lerna.js.map +1 -1
- package/lib/common/clients/npm.d.ts +4 -1
- package/lib/common/clients/npm.js +37 -16
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.d.ts +4 -0
- package/lib/common/clients/pnpm.js +43 -9
- package/lib/common/clients/pnpm.js.map +1 -1
- package/lib/common/clients/rush.d.ts +6 -0
- package/lib/common/clients/rush.js +118 -0
- package/lib/common/clients/rush.js.map +1 -0
- package/lib/common/clients/yarn.d.ts +4 -0
- package/lib/common/clients/yarn.js +45 -11
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/declaration.js +12 -9
- package/lib/common/declaration.js.map +1 -1
- package/lib/common/emulator.js +2 -2
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/http.d.ts +4 -2
- package/lib/common/http.js +35 -16
- package/lib/common/http.js.map +1 -1
- package/lib/common/info.d.ts +4 -0
- package/lib/common/info.js +6 -1
- package/lib/common/info.js.map +1 -1
- package/lib/common/injectors.d.ts +36 -7
- package/lib/common/injectors.js +39 -11
- package/lib/common/injectors.js.map +1 -1
- package/lib/common/inspect.js +2 -1
- package/lib/common/inspect.js.map +1 -1
- package/lib/common/interactive.d.ts +9 -0
- package/lib/common/interactive.js +33 -1
- package/lib/common/interactive.js.map +1 -1
- package/lib/common/io.js +1 -1
- package/lib/common/io.js.map +1 -1
- package/lib/common/log.d.ts +1 -0
- package/lib/common/log.js +9 -2
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.d.ts +9 -16
- package/lib/common/npm.js +110 -152
- package/lib/common/npm.js.map +1 -1
- package/lib/common/pack.js +1 -1
- package/lib/common/pack.js.map +1 -1
- package/lib/common/package.d.ts +6 -6
- package/lib/common/package.js +13 -4
- package/lib/common/package.js.map +1 -1
- package/lib/common/port.d.ts +1 -0
- package/lib/common/port.js +11 -1
- package/lib/common/port.js.map +1 -1
- package/lib/common/scaffold.js +5 -2
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/version.js +4 -4
- package/lib/common/version.js.map +1 -1
- package/lib/external/index.js +1982 -92
- package/lib/helpers.d.ts +3 -3
- package/lib/helpers.js +10 -10
- package/lib/helpers.js.map +1 -1
- package/lib/injectors/{pilet.d.ts → pilet-injector.d.ts} +1 -0
- package/lib/injectors/{pilet.js → pilet-injector.js} +29 -31
- package/lib/injectors/pilet-injector.js.map +1 -0
- package/lib/injectors/{piral.d.ts → piral-injector.d.ts} +1 -0
- package/lib/injectors/{piral.js → piral-injector.js} +20 -22
- package/lib/injectors/piral-injector.js.map +1 -0
- package/lib/messages.d.ts +79 -1
- package/lib/messages.js +89 -2
- package/lib/messages.js.map +1 -1
- package/lib/plugin.js +27 -2
- package/lib/plugin.js.map +1 -1
- package/lib/release.d.ts +1 -1
- package/lib/release.js +35 -3
- package/lib/release.js.map +1 -1
- package/lib/types/common.d.ts +1 -1
- package/lib/types/internal.d.ts +9 -1
- package/lib/types/public.d.ts +1 -1
- package/package.json +6 -4
- package/src/apps/debug-pilet.ts +28 -48
- package/src/apps/debug-piral.ts +22 -37
- package/src/apps/new-pilet.ts +9 -14
- package/src/apps/new-piral.ts +16 -5
- package/src/apps/publish-pilet.ts +10 -3
- package/src/apps/publish-piral.ts +21 -6
- package/src/apps/upgrade-pilet.ts +4 -12
- package/src/apps/upgrade-piral.ts +2 -2
- package/src/bundler.test.ts +1 -1
- package/src/bundler.ts +2 -2
- package/src/commands.ts +17 -9
- package/src/common/browser.ts +12 -8
- package/src/common/clients/index.ts +33 -0
- package/src/common/clients/lerna.ts +61 -1
- package/src/common/clients/npm.ts +32 -15
- package/src/common/clients/pnpm.ts +39 -10
- package/src/common/clients/rush.ts +111 -0
- package/src/common/clients/yarn.ts +41 -12
- package/src/common/declaration.ts +15 -9
- package/src/common/emulator.ts +3 -3
- package/src/common/http.ts +56 -19
- package/src/common/info.ts +6 -1
- package/src/common/injectors.ts +46 -17
- package/src/common/inspect.ts +2 -1
- package/src/common/interactive.test.ts +3 -0
- package/src/common/interactive.ts +49 -1
- package/src/common/io.ts +1 -1
- package/src/common/log.ts +9 -1
- package/src/common/npm.test.ts +109 -76
- package/src/common/npm.ts +119 -146
- package/src/common/pack.test.ts +1 -1
- package/src/common/pack.ts +2 -2
- package/src/common/package.ts +19 -10
- package/src/common/port.ts +10 -0
- package/src/common/scaffold.ts +6 -2
- package/src/common/version.ts +4 -4
- package/src/external/index.ts +2 -1
- package/src/helpers.test.ts +5 -5
- package/src/helpers.ts +7 -7
- package/src/injectors/{pilet.test.ts → pilet-injector.test.ts} +10 -1
- package/src/injectors/{pilet.ts → pilet-injector.ts} +36 -28
- package/src/injectors/{piral.test.ts → piral-injector.test.ts} +5 -1
- package/src/injectors/{piral.ts → piral-injector.ts} +24 -17
- package/src/messages.ts +88 -1
- package/src/plugin.ts +34 -5
- package/src/release.ts +47 -5
- package/src/types/common.ts +1 -1
- package/src/types/internal.ts +6 -1
- package/src/types/public.ts +1 -1
- package/lib/injectors/pilet.js.map +0 -1
- package/lib/injectors/piral.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { publishArtifacts } from '../release';
|
|
3
3
|
import { LogLevels, PiralBuildType } from '../types';
|
|
4
|
-
import { setLogLevel, progress, checkExists, fail, logDone, logReset,
|
|
4
|
+
import { setLogLevel, progress, checkExists, fail, logDone, logReset, publishNpmPackage, matchFiles } from '../common';
|
|
5
5
|
|
|
6
6
|
export interface PublishPiralOptions {
|
|
7
7
|
/**
|
|
@@ -19,6 +19,11 @@ export interface PublishPiralOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
fields?: Record<string, string>;
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Defines if authorization tokens can be retrieved interactively.
|
|
24
|
+
*/
|
|
25
|
+
interactive?: boolean;
|
|
26
|
+
|
|
22
27
|
/**
|
|
23
28
|
* The provider to use for publishing the release artifacts.
|
|
24
29
|
*/
|
|
@@ -36,9 +41,15 @@ export const publishPiralDefaults: PublishPiralOptions = {
|
|
|
36
41
|
type: 'all',
|
|
37
42
|
provider: 'none',
|
|
38
43
|
fields: {},
|
|
44
|
+
interactive: false,
|
|
39
45
|
};
|
|
40
46
|
|
|
41
|
-
async function publishEmulator(
|
|
47
|
+
async function publishEmulator(
|
|
48
|
+
baseDir: string,
|
|
49
|
+
source: string,
|
|
50
|
+
args: Record<string, string> = {},
|
|
51
|
+
interactive = false,
|
|
52
|
+
) {
|
|
42
53
|
const type = 'emulator';
|
|
43
54
|
const directory = resolve(baseDir, source, type);
|
|
44
55
|
const exists = await checkExists(directory);
|
|
@@ -58,7 +69,9 @@ async function publishEmulator(baseDir: string, source: string, args: Record<str
|
|
|
58
69
|
p.push(`--${c}`, args[c]);
|
|
59
70
|
return p;
|
|
60
71
|
}, [] as Array<string>);
|
|
61
|
-
|
|
72
|
+
|
|
73
|
+
//TODO support interactive here, too?
|
|
74
|
+
await publishNpmPackage(directory, file, flags);
|
|
62
75
|
}
|
|
63
76
|
|
|
64
77
|
async function publishRelease(
|
|
@@ -66,6 +79,7 @@ async function publishRelease(
|
|
|
66
79
|
source: string,
|
|
67
80
|
providerName: string,
|
|
68
81
|
args: Record<string, string> = {},
|
|
82
|
+
interactive = false,
|
|
69
83
|
) {
|
|
70
84
|
const type = 'release';
|
|
71
85
|
const directory = resolve(baseDir, source, type);
|
|
@@ -76,7 +90,7 @@ async function publishRelease(
|
|
|
76
90
|
}
|
|
77
91
|
|
|
78
92
|
const files = await matchFiles(directory, '**/*');
|
|
79
|
-
await publishArtifacts(providerName, files, args);
|
|
93
|
+
await publishArtifacts(providerName, directory, files, args, interactive);
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
export async function publishPiral(baseDir = process.cwd(), options: PublishPiralOptions = {}) {
|
|
@@ -86,6 +100,7 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
|
|
|
86
100
|
logLevel = publishPiralDefaults.logLevel,
|
|
87
101
|
fields = publishPiralDefaults.fields,
|
|
88
102
|
provider = publishPiralDefaults.provider,
|
|
103
|
+
interactive = publishPiralDefaults.interactive,
|
|
89
104
|
} = options;
|
|
90
105
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
91
106
|
setLogLevel(logLevel);
|
|
@@ -98,14 +113,14 @@ export async function publishPiral(baseDir = process.cwd(), options: PublishPira
|
|
|
98
113
|
|
|
99
114
|
if (type !== 'release') {
|
|
100
115
|
progress('Publishing emulator package ...');
|
|
101
|
-
await publishEmulator(fullBase, source, fields);
|
|
116
|
+
await publishEmulator(fullBase, source, fields, interactive);
|
|
102
117
|
logDone(`Successfully published emulator.`);
|
|
103
118
|
logReset();
|
|
104
119
|
}
|
|
105
120
|
|
|
106
121
|
if (type !== 'emulator') {
|
|
107
122
|
progress('Publishing release files ...');
|
|
108
|
-
await publishRelease(fullBase, source, provider, fields);
|
|
123
|
+
await publishRelease(fullBase, source, provider, fields, interactive);
|
|
109
124
|
logDone(`Successfully published release.`);
|
|
110
125
|
logReset();
|
|
111
126
|
}
|
|
@@ -2,7 +2,7 @@ import { resolve } from 'path';
|
|
|
2
2
|
import { LogLevels, NpmClientType } from '../types';
|
|
3
3
|
import {
|
|
4
4
|
readJson,
|
|
5
|
-
|
|
5
|
+
installNpmPackage,
|
|
6
6
|
checkExistingDirectory,
|
|
7
7
|
patchPiletPackage,
|
|
8
8
|
copyPiralFiles,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
readPiralPackage,
|
|
11
11
|
getPiletsInfo,
|
|
12
12
|
runScript,
|
|
13
|
-
|
|
13
|
+
installNpmDependencies,
|
|
14
14
|
getCurrentPackageDetails,
|
|
15
15
|
checkAppShellPackage,
|
|
16
16
|
setLogLevel,
|
|
@@ -22,8 +22,6 @@ import {
|
|
|
22
22
|
ForceOverwrite,
|
|
23
23
|
copyScaffoldingFiles,
|
|
24
24
|
getPiralPath,
|
|
25
|
-
detectMonorepo,
|
|
26
|
-
bootstrapMonorepo,
|
|
27
25
|
isMonorepoPackageRef,
|
|
28
26
|
getPiletScaffoldData,
|
|
29
27
|
SourceLanguage,
|
|
@@ -131,7 +129,7 @@ export async function upgradePilet(baseDir = process.cwd(), options: UpgradePile
|
|
|
131
129
|
if (!monorepoRef) {
|
|
132
130
|
// only install the latest if the shell does come from remote
|
|
133
131
|
progress(`Updating npm package to %s ...`, packageRef);
|
|
134
|
-
await
|
|
132
|
+
await installNpmPackage(npmClient, packageRef, root, '--no-save');
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
const piralInfo = await readPiralPackage(root, sourceName);
|
|
@@ -164,13 +162,7 @@ export async function upgradePilet(baseDir = process.cwd(), options: UpgradePile
|
|
|
164
162
|
|
|
165
163
|
if (install) {
|
|
166
164
|
progress(`Updating dependencies ...`);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
if (monorepoKind === 'lerna') {
|
|
170
|
-
await bootstrapMonorepo(root);
|
|
171
|
-
} else {
|
|
172
|
-
await installDependencies(npmClient, root);
|
|
173
|
-
}
|
|
165
|
+
await installNpmDependencies(npmClient, root);
|
|
174
166
|
}
|
|
175
167
|
|
|
176
168
|
if (postUpgrade) {
|
|
@@ -3,7 +3,7 @@ import { LogLevels, NpmClientType } from '../types';
|
|
|
3
3
|
import {
|
|
4
4
|
readJson,
|
|
5
5
|
checkExistingDirectory,
|
|
6
|
-
|
|
6
|
+
installNpmDependencies,
|
|
7
7
|
setLogLevel,
|
|
8
8
|
progress,
|
|
9
9
|
fail,
|
|
@@ -113,7 +113,7 @@ export async function upgradePiral(baseDir = process.cwd(), options: UpgradePira
|
|
|
113
113
|
|
|
114
114
|
if (install) {
|
|
115
115
|
progress(`Updating the npm packages to %s ...`, version);
|
|
116
|
-
await
|
|
116
|
+
await installNpmDependencies(npmClient, root);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
logDone('Piral instance upgraded successfully!');
|
package/src/bundler.test.ts
CHANGED
package/src/bundler.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { callDynamic, callStatic } from './build/bundler-calls';
|
|
2
2
|
import { availableBundlers } from './helpers';
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
installNpmPackage,
|
|
5
5
|
cliVersion,
|
|
6
6
|
fail,
|
|
7
7
|
progress,
|
|
@@ -39,7 +39,7 @@ async function installDefaultBundler(root: string) {
|
|
|
39
39
|
const client = await determineNpmClient(root);
|
|
40
40
|
log('generalDebug_0003', `Prepare to install ${selectedPackage}@${cliVersion} using "${client}" into "${root}".`);
|
|
41
41
|
progress(`Installing ${selectedPackage} ...`);
|
|
42
|
-
await
|
|
42
|
+
await installNpmPackage(client, `${selectedPackage}@${cliVersion}`, root, '--save-dev', '--save-exact');
|
|
43
43
|
log('generalDebug_0003', `Installed bundler from "${selectedPackage}".`);
|
|
44
44
|
|
|
45
45
|
require('./inject').inject(selectedPackage);
|
package/src/commands.ts
CHANGED
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
forceOverwriteKeys,
|
|
7
7
|
keyOfForceOverwrite,
|
|
8
8
|
valueOfForceOverwrite,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
keyOfSourceLanguage,
|
|
10
|
+
sourceLanguageKeys,
|
|
11
|
+
valueOfSourceLanguage,
|
|
12
12
|
frameworkKeys,
|
|
13
13
|
clientTypeKeys,
|
|
14
14
|
schemaKeys,
|
|
@@ -208,6 +208,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
208
208
|
.option('fields', undefined)
|
|
209
209
|
.describe('fields', 'Sets additional fields to be included in the feed service request.')
|
|
210
210
|
.default('fields', apps.publishPiralDefaults.fields)
|
|
211
|
+
.boolean('interactive')
|
|
212
|
+
.describe('interactive', 'Defines if authorization tokens can be retrieved interactively.')
|
|
213
|
+
.default('interactive', apps.publishPiralDefaults.interactive)
|
|
211
214
|
.string('base')
|
|
212
215
|
.default('base', process.cwd())
|
|
213
216
|
.describe('base', 'Sets the base directory. By default the current directory is used.');
|
|
@@ -219,6 +222,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
219
222
|
type: args.type as PiralBuildType,
|
|
220
223
|
provider: args.provider as string,
|
|
221
224
|
fields: args.fields as Record<string, string>,
|
|
225
|
+
interactive: args.interactive as boolean,
|
|
222
226
|
});
|
|
223
227
|
},
|
|
224
228
|
},
|
|
@@ -293,9 +297,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
293
297
|
.choices('force-overwrite', forceOverwriteKeys)
|
|
294
298
|
.describe('force-overwrite', 'Determines if files should be overwritten by the installation.')
|
|
295
299
|
.default('force-overwrite', keyOfForceOverwrite(apps.newPiralDefaults.forceOverwrite))
|
|
296
|
-
.choices('language',
|
|
300
|
+
.choices('language', sourceLanguageKeys)
|
|
297
301
|
.describe('language', 'Determines the programming language for the new Piral instance.')
|
|
298
|
-
.default('language',
|
|
302
|
+
.default('language', keyOfSourceLanguage(apps.newPiralDefaults.language))
|
|
299
303
|
.string('template')
|
|
300
304
|
.describe('template', 'Sets the boilerplate template package to be used when scaffolding.')
|
|
301
305
|
.default('template', apps.newPiralDefaults.template)
|
|
@@ -320,7 +324,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
320
324
|
version: args.tag as string,
|
|
321
325
|
registry: args.registry as string,
|
|
322
326
|
forceOverwrite: valueOfForceOverwrite(args['force-overwrite'] as string),
|
|
323
|
-
language:
|
|
327
|
+
language: valueOfSourceLanguage(args.language as string),
|
|
324
328
|
install: args.install as boolean,
|
|
325
329
|
template: args.template as string,
|
|
326
330
|
logLevel: args['log-level'] as LogLevels,
|
|
@@ -623,6 +627,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
623
627
|
.option('headers', undefined)
|
|
624
628
|
.describe('headers', 'Sets additional headers to be included in the feed service request.')
|
|
625
629
|
.default('headers', apps.publishPiletDefaults.headers)
|
|
630
|
+
.boolean('interactive')
|
|
631
|
+
.describe('interactive', 'Defines if authorization tokens can be retrieved interactively.')
|
|
632
|
+
.default('interactive', apps.publishPiletDefaults.interactive)
|
|
626
633
|
.string('base')
|
|
627
634
|
.default('base', process.cwd())
|
|
628
635
|
.describe('base', 'Sets the base directory. By default the current directory is used.');
|
|
@@ -641,6 +648,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
641
648
|
fields: args.fields as Record<string, string>,
|
|
642
649
|
headers: args.headers as Record<string, string>,
|
|
643
650
|
mode: args.mode as PiletPublishScheme,
|
|
651
|
+
interactive: args.interactive as boolean,
|
|
644
652
|
_: args,
|
|
645
653
|
});
|
|
646
654
|
},
|
|
@@ -674,9 +682,9 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
674
682
|
.number('log-level')
|
|
675
683
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
676
684
|
.default('log-level', apps.newPiletDefaults.logLevel)
|
|
677
|
-
.choices('language',
|
|
685
|
+
.choices('language', sourceLanguageKeys)
|
|
678
686
|
.describe('language', 'Determines the programming language for the new pilet.')
|
|
679
|
-
.default('language',
|
|
687
|
+
.default('language', keyOfSourceLanguage(apps.newPiletDefaults.language))
|
|
680
688
|
.string('template')
|
|
681
689
|
.describe('template', 'Sets the boilerplate template package to be used when scaffolding.')
|
|
682
690
|
.default('template', apps.newPiletDefaults.template)
|
|
@@ -699,7 +707,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
699
707
|
source: args.source as string,
|
|
700
708
|
registry: args.registry as string,
|
|
701
709
|
forceOverwrite: valueOfForceOverwrite(args['force-overwrite'] as string),
|
|
702
|
-
language:
|
|
710
|
+
language: valueOfSourceLanguage(args.language as string),
|
|
703
711
|
logLevel: args['log-level'] as LogLevels,
|
|
704
712
|
install: args.install as boolean,
|
|
705
713
|
template: args.template as string,
|
package/src/common/browser.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { log } from './log';
|
|
2
|
-
import { open } from '../external';
|
|
3
2
|
import { config } from './config';
|
|
3
|
+
import { open } from '../external';
|
|
4
|
+
|
|
5
|
+
export async function openBrowserAt(address: string) {
|
|
6
|
+
try {
|
|
7
|
+
await open(address, undefined);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
log('failedToOpenBrowser_0170', err);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
4
12
|
|
|
5
13
|
export async function openBrowser(shouldOpen: boolean, port: number, path: string, https?: boolean) {
|
|
6
14
|
if (shouldOpen) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
await open(address, undefined);
|
|
11
|
-
} catch (err) {
|
|
12
|
-
log('failedToOpenBrowser_0170', err);
|
|
13
|
-
}
|
|
15
|
+
const scheme = https ? 'https' : 'http';
|
|
16
|
+
const address = `${scheme}://${config.host}:${port}${path}`;
|
|
17
|
+
await openBrowserAt(address);
|
|
14
18
|
}
|
|
15
19
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as lerna from './lerna';
|
|
2
|
+
import * as npm from './npm';
|
|
3
|
+
import * as pnpm from './pnpm';
|
|
4
|
+
import * as rush from './rush';
|
|
5
|
+
import * as yarn from './yarn';
|
|
6
|
+
|
|
7
|
+
export const clients = {
|
|
8
|
+
lerna,
|
|
9
|
+
npm,
|
|
10
|
+
pnpm,
|
|
11
|
+
rush,
|
|
12
|
+
yarn,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type ClientName = keyof typeof clients;
|
|
16
|
+
|
|
17
|
+
const directClients = ['npm', 'yarn', 'pnpm'];
|
|
18
|
+
|
|
19
|
+
export function isWrapperClient(client: ClientName) {
|
|
20
|
+
return !directClients.includes(client);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function detectClients(root: string) {
|
|
24
|
+
return Promise.all(
|
|
25
|
+
Object.keys(clients).map(async (client: ClientName) => {
|
|
26
|
+
const result = await clients[client].detectClient(root);
|
|
27
|
+
return {
|
|
28
|
+
client,
|
|
29
|
+
result,
|
|
30
|
+
};
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
@@ -1,17 +1,77 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { log } from '../log';
|
|
3
|
+
import { findFile } from '../io';
|
|
3
4
|
import { runCommand } from '../scripts';
|
|
4
5
|
import { MemoryStream } from '../MemoryStream';
|
|
5
6
|
|
|
7
|
+
// Helpers:
|
|
8
|
+
|
|
6
9
|
function runLernaProcess(args: Array<string>, target: string, output?: NodeJS.WritableStream) {
|
|
7
10
|
log('generalDebug_0003', 'Starting the Lerna process ...');
|
|
8
11
|
const cwd = resolve(process.cwd(), target);
|
|
9
12
|
return runCommand('lerna', args, cwd, output);
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
function convert(flags: Array<string>) {
|
|
16
|
+
return flags.map((flag) => {
|
|
17
|
+
switch (flag) {
|
|
18
|
+
case '--save-exact':
|
|
19
|
+
return '--exact';
|
|
20
|
+
case '--save-dev':
|
|
21
|
+
return '--dev';
|
|
22
|
+
case '--no-save':
|
|
23
|
+
// unfortunately no
|
|
24
|
+
return '';
|
|
25
|
+
default:
|
|
26
|
+
return flag;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Client interface functions:
|
|
32
|
+
|
|
33
|
+
export async function installDependencies(target = '.', ...flags: Array<string>) {
|
|
13
34
|
const ms = new MemoryStream();
|
|
14
35
|
await runLernaProcess(['bootstrap', ...flags], target, ms);
|
|
15
36
|
log('generalDebug_0003', `Lerna bootstrap result: ${ms.value}`);
|
|
16
37
|
return ms.value;
|
|
17
38
|
}
|
|
39
|
+
|
|
40
|
+
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
41
|
+
const ms = new MemoryStream();
|
|
42
|
+
await runLernaProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
43
|
+
log('generalDebug_0003', `Lerna install package result: ${ms.value}`);
|
|
44
|
+
return ms.value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function detectClient(root: string) {
|
|
48
|
+
return !!(await findFile(root, 'lerna.json'));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function initProject(projectName: string, target: string) {}
|
|
52
|
+
|
|
53
|
+
export async function isProject(root: string, packageRef: string) {
|
|
54
|
+
const projects = await listProjects(root);
|
|
55
|
+
|
|
56
|
+
if (Array.isArray(projects)) {
|
|
57
|
+
return projects?.some((p) => p.name === packageRef) ?? false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Functions to exclusively use from lerna client:
|
|
64
|
+
|
|
65
|
+
export async function listProjects(target: string) {
|
|
66
|
+
const ms = new MemoryStream();
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
await runLernaProcess(['list', '--json', '-p'], target, ms);
|
|
70
|
+
} catch (e) {
|
|
71
|
+
log('generalDebug_0003', `lerna list error: ${e}`);
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
log('generalDebug_0003', `lerna list project result: ${ms.value}`);
|
|
76
|
+
return JSON.parse(ms.value);
|
|
77
|
+
}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { log } from '../log';
|
|
3
|
+
import { findFile } from '../io';
|
|
3
4
|
import { runCommand } from '../scripts';
|
|
4
5
|
import { MemoryStream } from '../MemoryStream';
|
|
5
6
|
|
|
7
|
+
// Helpers:
|
|
8
|
+
|
|
6
9
|
function runNpmProcess(args: Array<string>, target: string, output?: NodeJS.WritableStream) {
|
|
7
10
|
log('generalDebug_0003', 'Starting the npm process ...');
|
|
8
11
|
const cwd = resolve(process.cwd(), target);
|
|
9
12
|
return runCommand('npm', args, cwd, output);
|
|
10
13
|
}
|
|
11
14
|
|
|
15
|
+
// Client interface functions:
|
|
16
|
+
|
|
12
17
|
export async function installDependencies(target = '.', ...flags: Array<string>) {
|
|
13
18
|
const ms = new MemoryStream();
|
|
14
19
|
await runNpmProcess(['install', '--legacy-peer-deps', ...flags], target, ms);
|
|
@@ -16,26 +21,37 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
16
21
|
return ms.value;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
export async function
|
|
24
|
+
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
20
25
|
const ms = new MemoryStream();
|
|
21
|
-
await runNpmProcess(['
|
|
22
|
-
log('generalDebug_0003', `npm
|
|
26
|
+
await runNpmProcess(['install', packageRef, '--legacy-peer-deps', ...flags], target, ms);
|
|
27
|
+
log('generalDebug_0003', `npm install package result: ${ms.value}`);
|
|
23
28
|
return ms.value;
|
|
24
29
|
}
|
|
25
30
|
|
|
26
|
-
export async function
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
);
|
|
37
|
-
throw ex;
|
|
31
|
+
export async function detectClient(root: string) {
|
|
32
|
+
return !!(await findFile(root, 'package-lock.json'));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function isProject(root: string, packageRef: string) {
|
|
36
|
+
const details = await listPackage(packageRef, root);
|
|
37
|
+
const packageDetails = details?.dependencies?.[packageRef];
|
|
38
|
+
|
|
39
|
+
if (packageDetails && typeof packageDetails.resolved === 'string') {
|
|
40
|
+
return packageDetails.resolved.startsWith('file:');
|
|
38
41
|
}
|
|
42
|
+
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function initProject(projectName: string, target: string) {}
|
|
47
|
+
|
|
48
|
+
// Functions to exclusively use from npm client:
|
|
49
|
+
|
|
50
|
+
export async function unpackPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
51
|
+
const ms = new MemoryStream();
|
|
52
|
+
await runNpmProcess(['pack', packageRef, ...flags], target, ms);
|
|
53
|
+
log('generalDebug_0003', `npm (un)pack result: ${ms.value}`);
|
|
54
|
+
return ms.value;
|
|
39
55
|
}
|
|
40
56
|
|
|
41
57
|
export async function createPackage(target = '.', ...flags: Array<string>) {
|
|
@@ -73,6 +89,7 @@ export async function listPackage(packageRef: string, target = '.', ...flags: Ar
|
|
|
73
89
|
await runNpmProcess(['ls', packageRef, '--json', '--depth', '0', ...flags], target, ms);
|
|
74
90
|
} catch (e) {
|
|
75
91
|
log('generalDebug_0003', `npm ls packageRef error: ${e}`);
|
|
92
|
+
return {};
|
|
76
93
|
}
|
|
77
94
|
|
|
78
95
|
log('generalDebug_0003', `npm ls packageRef result: ${ms.value}`);
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { log } from '../log';
|
|
3
|
+
import { findFile } from '../io';
|
|
3
4
|
import { runCommand } from '../scripts';
|
|
4
5
|
import { MemoryStream } from '../MemoryStream';
|
|
5
6
|
|
|
7
|
+
// Helpers:
|
|
8
|
+
|
|
6
9
|
function runPnpmProcess(args: Array<string>, target: string, output?: NodeJS.WritableStream) {
|
|
7
10
|
log('generalDebug_0003', 'Starting the Pnpm process ...');
|
|
8
11
|
const cwd = resolve(process.cwd(), target);
|
|
@@ -21,6 +24,8 @@ function convert(flags: Array<string>) {
|
|
|
21
24
|
});
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
// Client interface functions:
|
|
28
|
+
|
|
24
29
|
export async function installDependencies(target = '.', ...flags: Array<string>) {
|
|
25
30
|
const ms = new MemoryStream();
|
|
26
31
|
await runPnpmProcess(['install', ...convert(flags)], target, ms);
|
|
@@ -29,16 +34,40 @@ export async function installDependencies(target = '.', ...flags: Array<string>)
|
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
37
|
+
const ms = new MemoryStream();
|
|
38
|
+
await runPnpmProcess(['add', packageRef, ...convert(flags)], target, ms);
|
|
39
|
+
log('generalDebug_0003', `Pnpm install package result: ${ms.value}`);
|
|
40
|
+
return ms.value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function detectClient(root: string) {
|
|
44
|
+
return !!(await findFile(root, 'pnpm-lock.yaml'));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function initProject(projectName: string, target: string) {}
|
|
48
|
+
|
|
49
|
+
export async function isProject(root: string, packageRef: string) {
|
|
50
|
+
const projects = await listProjects(root);
|
|
51
|
+
|
|
52
|
+
if (Array.isArray(projects)) {
|
|
53
|
+
return projects?.some((p) => p.name === packageRef) ?? false;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Functions to exclusively use from pnpm client:
|
|
60
|
+
|
|
61
|
+
export async function listProjects(target: string) {
|
|
62
|
+
const ms = new MemoryStream();
|
|
63
|
+
|
|
32
64
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
log('generalDebug_0003', `
|
|
36
|
-
return
|
|
37
|
-
} catch (ex) {
|
|
38
|
-
log(
|
|
39
|
-
'generalError_0002',
|
|
40
|
-
`Could not install the package "${packageRef}" using Pnpm. Make sure Pnpm is correctly installed and accessible: ${ex}`,
|
|
41
|
-
);
|
|
42
|
-
throw ex;
|
|
65
|
+
await runPnpmProcess(['list', '--json', '--recursive', '--depth', '0'], target, ms);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
log('generalDebug_0003', `pnpm list error: ${e}`);
|
|
68
|
+
return [];
|
|
43
69
|
}
|
|
70
|
+
|
|
71
|
+
log('generalDebug_0003', `pnpm list project result: ${ms.value}`);
|
|
72
|
+
return JSON.parse(ms.value);
|
|
44
73
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { dirname, relative, resolve } from 'path';
|
|
2
|
+
import { log } from '../log';
|
|
3
|
+
import { findFile, readText, writeText } from '../io';
|
|
4
|
+
import { jju } from '../../external';
|
|
5
|
+
import { runCommand } from '../scripts';
|
|
6
|
+
import { MemoryStream } from '../MemoryStream';
|
|
7
|
+
|
|
8
|
+
// Helpers:
|
|
9
|
+
const rushJson = 'rush.json';
|
|
10
|
+
|
|
11
|
+
function runRushProcess(args: Array<string>, target: string, output?: NodeJS.WritableStream) {
|
|
12
|
+
log('generalDebug_0003', 'Starting the Rush process ...');
|
|
13
|
+
const cwd = resolve(process.cwd(), target);
|
|
14
|
+
return runCommand('rush', args, cwd, output);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function convert(flags: Array<string>) {
|
|
18
|
+
return flags.map((flag) => {
|
|
19
|
+
switch (flag) {
|
|
20
|
+
case '--save-exact':
|
|
21
|
+
// discard as this may lead to problems
|
|
22
|
+
return '';
|
|
23
|
+
case '--save-dev':
|
|
24
|
+
return '--dev';
|
|
25
|
+
case '--no-save':
|
|
26
|
+
// unfortunately no
|
|
27
|
+
return '';
|
|
28
|
+
default:
|
|
29
|
+
return flag;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Client interface functions:
|
|
35
|
+
|
|
36
|
+
export async function installDependencies(target = '.', ...flags: Array<string>) {
|
|
37
|
+
const ms = new MemoryStream();
|
|
38
|
+
await runRushProcess(['update', ...convert(flags)], target, ms);
|
|
39
|
+
log('generalDebug_0003', `Rush install dependencies result: ${ms.value}`);
|
|
40
|
+
return ms.value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function installPackage(packageRef: string, target = '.', ...flags: Array<string>) {
|
|
44
|
+
const ms = new MemoryStream();
|
|
45
|
+
await runRushProcess(['add', '--package', packageRef, ...convert(flags)], target, ms);
|
|
46
|
+
log('generalDebug_0003', `Rush install package result: ${ms.value}`);
|
|
47
|
+
return ms.value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function detectClient(root: string) {
|
|
51
|
+
return !!(await findFile(root, rushJson));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function initProject(packageName: string, target: string) {
|
|
55
|
+
const rushPath = await findFile(target, rushJson);
|
|
56
|
+
|
|
57
|
+
if (!rushPath) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Could not find the "${rushJson}" from "${target}". Sure you want to create the project in the right directory?`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const rushDir = dirname(rushPath);
|
|
64
|
+
const rushContent = await readText(rushDir, rushJson);
|
|
65
|
+
const rushData = jju.parse(rushContent);
|
|
66
|
+
const projectFolder = relative(rushDir, target);
|
|
67
|
+
|
|
68
|
+
if (!Array.isArray(rushData.projects)) {
|
|
69
|
+
rushData.projects = [];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
rushData.projects.push({
|
|
73
|
+
packageName,
|
|
74
|
+
projectFolder,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
await writeText(
|
|
78
|
+
rushDir,
|
|
79
|
+
rushJson,
|
|
80
|
+
jju.update(rushContent, rushData, {
|
|
81
|
+
mode: 'cjson',
|
|
82
|
+
indent: 2,
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function isProject(root: string, packageRef: string) {
|
|
88
|
+
const details = await listProjects(root);
|
|
89
|
+
|
|
90
|
+
if (typeof details === 'object' && Array.isArray(details?.projects)) {
|
|
91
|
+
return details?.projects?.some((p) => p.name === packageRef) ?? false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Functions to exclusively use from rush client:
|
|
98
|
+
|
|
99
|
+
export async function listProjects(target: string) {
|
|
100
|
+
const ms = new MemoryStream();
|
|
101
|
+
|
|
102
|
+
try {
|
|
103
|
+
await runRushProcess(['list', '--json'], target, ms);
|
|
104
|
+
} catch (e) {
|
|
105
|
+
log('generalDebug_0003', `rush list error: ${e}`);
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
log('generalDebug_0003', `rush list project result: ${ms.value}`);
|
|
110
|
+
return JSON.parse(ms.value);
|
|
111
|
+
}
|