piral-cli 0.15.0-alpha.4041 → 0.15.0-alpha.4231
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/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/index.js +5 -1
- package/lib/apps/index.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 +5 -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/build/bundler-calls.d.ts +1 -1
- package/lib/build/run-build-pilet.js.map +1 -1
- package/lib/build/run-build-piral.js.map +1 -1
- package/lib/build/run-debug-mono-piral.js +1 -1
- package/lib/build/run-debug-mono-piral.js.map +1 -1
- package/lib/build/run-debug-pilet.js.map +1 -1
- package/lib/build/run-debug-piral.js.map +1 -1
- package/lib/bundler.js +1 -1
- package/lib/bundler.js.map +1 -1
- package/lib/commands.js +8 -0
- 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 +36 -9
- package/lib/common/clients/npm.js.map +1 -1
- package/lib/common/clients/pnpm.d.ts +4 -0
- package/lib/common/clients/pnpm.js +41 -1
- 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 +44 -4
- package/lib/common/clients/yarn.js.map +1 -1
- package/lib/common/config.js.map +1 -1
- package/lib/common/constants.d.ts +1 -1
- package/lib/common/constants.js +1 -1
- package/lib/common/constants.js.map +1 -1
- package/lib/common/declaration.js +14 -10
- 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 +1 -1
- package/lib/common/http.js +12 -7
- package/lib/common/http.js.map +1 -1
- package/lib/common/importmap.js +7 -16
- package/lib/common/importmap.js.map +1 -1
- package/lib/common/index.js +5 -1
- package/lib/common/index.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/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 +31 -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/npm.d.ts +11 -16
- package/lib/common/npm.js +165 -158
- 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 -7
- package/lib/common/package.js +26 -28
- package/lib/common/package.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 +2380 -470
- package/lib/helpers.d.ts +1 -1
- package/lib/helpers.js +1 -1
- package/lib/helpers.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/injectors/pilet.d.ts +1 -0
- package/lib/injectors/pilet.js +7 -7
- package/lib/injectors/pilet.js.map +1 -1
- package/lib/messages.d.ts +1 -1
- package/lib/messages.js +5 -1
- 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 +7 -2
- package/lib/release.js.map +1 -1
- package/lib/types/common.d.ts +1 -1
- package/lib/types/index.js +5 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/internal.d.ts +9 -1
- package/lib/types/public.d.ts +2 -2
- package/package.json +5 -3
- package/src/apps/new-pilet.ts +9 -14
- package/src/apps/new-piral.ts +9 -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/build/bundler-calls.ts +1 -1
- package/src/build/run-build-pilet.ts +1 -1
- package/src/build/run-build-piral.ts +1 -1
- package/src/build/run-debug-mono-piral.ts +2 -2
- package/src/build/run-debug-pilet.ts +1 -1
- package/src/build/run-debug-piral.ts +1 -1
- package/src/bundler.test.ts +1 -1
- package/src/bundler.ts +2 -2
- package/src/commands.ts +8 -0
- 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 +31 -6
- package/src/common/clients/pnpm.ts +37 -0
- package/src/common/clients/rush.ts +111 -0
- package/src/common/clients/yarn.ts +40 -3
- package/src/common/config.ts +3 -3
- package/src/common/constants.ts +1 -1
- package/src/common/declaration.ts +17 -10
- package/src/common/emulator.ts +3 -3
- package/src/common/http.ts +20 -6
- package/src/common/importmap.ts +7 -15
- package/src/common/info.ts +6 -1
- package/src/common/inspect.ts +2 -1
- package/src/common/interactive.test.ts +3 -0
- package/src/common/interactive.ts +48 -1
- package/src/common/io.ts +1 -1
- package/src/common/npm.test.ts +122 -76
- package/src/common/npm.ts +177 -152
- package/src/common/pack.test.ts +1 -1
- package/src/common/pack.ts +2 -2
- package/src/common/package.test.ts +1 -14
- package/src/common/package.ts +31 -29
- package/src/common/scaffold.ts +7 -2
- package/src/common/version.ts +4 -4
- package/src/external/index.ts +2 -1
- package/src/helpers.ts +2 -2
- package/src/injectors/pilet.ts +9 -8
- package/src/messages.ts +6 -2
- package/src/plugin.ts +34 -5
- package/src/release.ts +10 -2
- package/src/types/common.ts +1 -1
- package/src/types/internal.ts +6 -1
- package/src/types/public.ts +2 -2
|
@@ -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, 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!');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
2
|
import { fork, ChildProcess } from 'child_process';
|
|
3
|
-
import { Bundler, BundleDetails, BaseBundleParameters } from '../types';
|
|
3
|
+
import type { Bundler, BundleDetails, BaseBundleParameters } from '../types';
|
|
4
4
|
|
|
5
5
|
function getPath(name: string) {
|
|
6
6
|
return resolve(__dirname, '..', '..', 'lib', 'build', `run-${name}.js`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PiletSchemaVersion, LogLevels, SharedDependency, PiletBuildHandler } from '../types';
|
|
2
1
|
import { setStandardEnvs } from '../common';
|
|
2
|
+
import type { PiletSchemaVersion, LogLevels, SharedDependency, PiletBuildHandler } from '../types';
|
|
3
3
|
|
|
4
4
|
let handler: PiletBuildHandler;
|
|
5
5
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { LogLevels, PiralBuildHandler } from '../types';
|
|
2
|
-
import { setStandardEnvs, progress, logReset } from '../common';
|
|
3
1
|
import { resolve } from 'path';
|
|
2
|
+
import { setStandardEnvs, progress, logReset } from '../common';
|
|
3
|
+
import type { LogLevels, PiralBuildHandler } from '../types';
|
|
4
4
|
|
|
5
5
|
let handler: PiralBuildHandler;
|
|
6
6
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { setStandardEnvs } from '../common';
|
|
1
2
|
import type {
|
|
2
3
|
PiletSchemaVersion,
|
|
3
4
|
LogLevels,
|
|
@@ -5,7 +6,6 @@ import type {
|
|
|
5
6
|
BundleHandlerResponse,
|
|
6
7
|
PiletBuildHandler,
|
|
7
8
|
} from '../types';
|
|
8
|
-
import { setStandardEnvs } from '../common';
|
|
9
9
|
|
|
10
10
|
let handler: PiletBuildHandler;
|
|
11
11
|
let bundler: BundleHandlerResponse;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { BundleHandlerResponse, LogLevels, PiralBuildHandler } from '../types';
|
|
2
1
|
import { setStandardEnvs } from '../common';
|
|
2
|
+
import type { BundleHandlerResponse, LogLevels, PiralBuildHandler } from '../types';
|
|
3
3
|
|
|
4
4
|
let handler: PiralBuildHandler;
|
|
5
5
|
let bundler: BundleHandlerResponse;
|
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
|
@@ -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
|
},
|
|
@@ -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
|
},
|
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,17 +21,36 @@ 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
|
|
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:');
|
|
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>) {
|
|
27
51
|
const ms = new MemoryStream();
|
|
28
|
-
await runNpmProcess(['
|
|
29
|
-
log('generalDebug_0003', `npm
|
|
52
|
+
await runNpmProcess(['pack', packageRef, ...flags], target, ms);
|
|
53
|
+
log('generalDebug_0003', `npm (un)pack result: ${ms.value}`);
|
|
30
54
|
return ms.value;
|
|
31
55
|
}
|
|
32
56
|
|
|
@@ -65,6 +89,7 @@ export async function listPackage(packageRef: string, target = '.', ...flags: Ar
|
|
|
65
89
|
await runNpmProcess(['ls', packageRef, '--json', '--depth', '0', ...flags], target, ms);
|
|
66
90
|
} catch (e) {
|
|
67
91
|
log('generalDebug_0003', `npm ls packageRef error: ${e}`);
|
|
92
|
+
return {};
|
|
68
93
|
}
|
|
69
94
|
|
|
70
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);
|
|
@@ -34,3 +39,35 @@ export async function installPackage(packageRef: string, target = '.', ...flags:
|
|
|
34
39
|
log('generalDebug_0003', `Pnpm install package result: ${ms.value}`);
|
|
35
40
|
return ms.value;
|
|
36
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
|
+
|
|
64
|
+
try {
|
|
65
|
+
await runPnpmProcess(['list', '--json', '--recursive', '--depth', '0'], target, ms);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
log('generalDebug_0003', `pnpm list error: ${e}`);
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
log('generalDebug_0003', `pnpm list project result: ${ms.value}`);
|
|
72
|
+
return JSON.parse(ms.value);
|
|
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
|
+
}
|