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.
Files changed (155) hide show
  1. package/README.md +7 -5
  2. package/lib/apps/debug-pilet.js +28 -42
  3. package/lib/apps/debug-pilet.js.map +1 -1
  4. package/lib/apps/debug-piral.js +20 -34
  5. package/lib/apps/debug-piral.js.map +1 -1
  6. package/lib/apps/new-pilet.js +5 -9
  7. package/lib/apps/new-pilet.js.map +1 -1
  8. package/lib/apps/new-piral.js +9 -3
  9. package/lib/apps/new-piral.js.map +1 -1
  10. package/lib/apps/publish-pilet.d.ts +4 -0
  11. package/lib/apps/publish-pilet.js +4 -3
  12. package/lib/apps/publish-pilet.js.map +1 -1
  13. package/lib/apps/publish-piral.d.ts +4 -0
  14. package/lib/apps/publish-piral.js +9 -7
  15. package/lib/apps/publish-piral.js.map +1 -1
  16. package/lib/apps/upgrade-pilet.js +2 -8
  17. package/lib/apps/upgrade-pilet.js.map +1 -1
  18. package/lib/apps/upgrade-piral.js +1 -1
  19. package/lib/apps/upgrade-piral.js.map +1 -1
  20. package/lib/bundler.js +1 -1
  21. package/lib/bundler.js.map +1 -1
  22. package/lib/commands.js +14 -6
  23. package/lib/commands.js.map +1 -1
  24. package/lib/common/browser.d.ts +1 -0
  25. package/lib/common/browser.js +16 -10
  26. package/lib/common/browser.js.map +1 -1
  27. package/lib/common/clients/index.d.ts +19 -0
  28. package/lib/common/clients/index.js +40 -0
  29. package/lib/common/clients/index.js.map +1 -0
  30. package/lib/common/clients/lerna.d.ts +6 -1
  31. package/lib/common/clients/lerna.js +67 -3
  32. package/lib/common/clients/lerna.js.map +1 -1
  33. package/lib/common/clients/npm.d.ts +4 -1
  34. package/lib/common/clients/npm.js +37 -16
  35. package/lib/common/clients/npm.js.map +1 -1
  36. package/lib/common/clients/pnpm.d.ts +4 -0
  37. package/lib/common/clients/pnpm.js +43 -9
  38. package/lib/common/clients/pnpm.js.map +1 -1
  39. package/lib/common/clients/rush.d.ts +6 -0
  40. package/lib/common/clients/rush.js +118 -0
  41. package/lib/common/clients/rush.js.map +1 -0
  42. package/lib/common/clients/yarn.d.ts +4 -0
  43. package/lib/common/clients/yarn.js +45 -11
  44. package/lib/common/clients/yarn.js.map +1 -1
  45. package/lib/common/declaration.js +12 -9
  46. package/lib/common/declaration.js.map +1 -1
  47. package/lib/common/emulator.js +2 -2
  48. package/lib/common/emulator.js.map +1 -1
  49. package/lib/common/http.d.ts +4 -2
  50. package/lib/common/http.js +35 -16
  51. package/lib/common/http.js.map +1 -1
  52. package/lib/common/info.d.ts +4 -0
  53. package/lib/common/info.js +6 -1
  54. package/lib/common/info.js.map +1 -1
  55. package/lib/common/injectors.d.ts +36 -7
  56. package/lib/common/injectors.js +39 -11
  57. package/lib/common/injectors.js.map +1 -1
  58. package/lib/common/inspect.js +2 -1
  59. package/lib/common/inspect.js.map +1 -1
  60. package/lib/common/interactive.d.ts +9 -0
  61. package/lib/common/interactive.js +33 -1
  62. package/lib/common/interactive.js.map +1 -1
  63. package/lib/common/io.js +1 -1
  64. package/lib/common/io.js.map +1 -1
  65. package/lib/common/log.d.ts +1 -0
  66. package/lib/common/log.js +9 -2
  67. package/lib/common/log.js.map +1 -1
  68. package/lib/common/npm.d.ts +9 -16
  69. package/lib/common/npm.js +110 -152
  70. package/lib/common/npm.js.map +1 -1
  71. package/lib/common/pack.js +1 -1
  72. package/lib/common/pack.js.map +1 -1
  73. package/lib/common/package.d.ts +6 -6
  74. package/lib/common/package.js +13 -4
  75. package/lib/common/package.js.map +1 -1
  76. package/lib/common/port.d.ts +1 -0
  77. package/lib/common/port.js +11 -1
  78. package/lib/common/port.js.map +1 -1
  79. package/lib/common/scaffold.js +5 -2
  80. package/lib/common/scaffold.js.map +1 -1
  81. package/lib/common/version.js +4 -4
  82. package/lib/common/version.js.map +1 -1
  83. package/lib/external/index.js +1982 -92
  84. package/lib/helpers.d.ts +3 -3
  85. package/lib/helpers.js +10 -10
  86. package/lib/helpers.js.map +1 -1
  87. package/lib/injectors/{pilet.d.ts → pilet-injector.d.ts} +1 -0
  88. package/lib/injectors/{pilet.js → pilet-injector.js} +29 -31
  89. package/lib/injectors/pilet-injector.js.map +1 -0
  90. package/lib/injectors/{piral.d.ts → piral-injector.d.ts} +1 -0
  91. package/lib/injectors/{piral.js → piral-injector.js} +20 -22
  92. package/lib/injectors/piral-injector.js.map +1 -0
  93. package/lib/messages.d.ts +79 -1
  94. package/lib/messages.js +89 -2
  95. package/lib/messages.js.map +1 -1
  96. package/lib/plugin.js +27 -2
  97. package/lib/plugin.js.map +1 -1
  98. package/lib/release.d.ts +1 -1
  99. package/lib/release.js +35 -3
  100. package/lib/release.js.map +1 -1
  101. package/lib/types/common.d.ts +1 -1
  102. package/lib/types/internal.d.ts +9 -1
  103. package/lib/types/public.d.ts +1 -1
  104. package/package.json +6 -4
  105. package/src/apps/debug-pilet.ts +28 -48
  106. package/src/apps/debug-piral.ts +22 -37
  107. package/src/apps/new-pilet.ts +9 -14
  108. package/src/apps/new-piral.ts +16 -5
  109. package/src/apps/publish-pilet.ts +10 -3
  110. package/src/apps/publish-piral.ts +21 -6
  111. package/src/apps/upgrade-pilet.ts +4 -12
  112. package/src/apps/upgrade-piral.ts +2 -2
  113. package/src/bundler.test.ts +1 -1
  114. package/src/bundler.ts +2 -2
  115. package/src/commands.ts +17 -9
  116. package/src/common/browser.ts +12 -8
  117. package/src/common/clients/index.ts +33 -0
  118. package/src/common/clients/lerna.ts +61 -1
  119. package/src/common/clients/npm.ts +32 -15
  120. package/src/common/clients/pnpm.ts +39 -10
  121. package/src/common/clients/rush.ts +111 -0
  122. package/src/common/clients/yarn.ts +41 -12
  123. package/src/common/declaration.ts +15 -9
  124. package/src/common/emulator.ts +3 -3
  125. package/src/common/http.ts +56 -19
  126. package/src/common/info.ts +6 -1
  127. package/src/common/injectors.ts +46 -17
  128. package/src/common/inspect.ts +2 -1
  129. package/src/common/interactive.test.ts +3 -0
  130. package/src/common/interactive.ts +49 -1
  131. package/src/common/io.ts +1 -1
  132. package/src/common/log.ts +9 -1
  133. package/src/common/npm.test.ts +109 -76
  134. package/src/common/npm.ts +119 -146
  135. package/src/common/pack.test.ts +1 -1
  136. package/src/common/pack.ts +2 -2
  137. package/src/common/package.ts +19 -10
  138. package/src/common/port.ts +10 -0
  139. package/src/common/scaffold.ts +6 -2
  140. package/src/common/version.ts +4 -4
  141. package/src/external/index.ts +2 -1
  142. package/src/helpers.test.ts +5 -5
  143. package/src/helpers.ts +7 -7
  144. package/src/injectors/{pilet.test.ts → pilet-injector.test.ts} +10 -1
  145. package/src/injectors/{pilet.ts → pilet-injector.ts} +36 -28
  146. package/src/injectors/{piral.test.ts → piral-injector.test.ts} +5 -1
  147. package/src/injectors/{piral.ts → piral-injector.ts} +24 -17
  148. package/src/messages.ts +88 -1
  149. package/src/plugin.ts +34 -5
  150. package/src/release.ts +47 -5
  151. package/src/types/common.ts +1 -1
  152. package/src/types/internal.ts +6 -1
  153. package/src/types/public.ts +1 -1
  154. package/lib/injectors/pilet.js.map +0 -1
  155. package/lib/injectors/piral.js.map +0 -1
package/lib/release.js CHANGED
@@ -13,11 +13,21 @@ exports.publishArtifacts = exports.setReleaseProvider = void 0;
13
13
  const path_1 = require("path");
14
14
  const common_1 = require("./common");
15
15
  const helpers_1 = require("./helpers");
16
+ function getVersion(directory) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const data = yield (0, common_1.findFile)(directory, 'package.json');
19
+ if (!data) {
20
+ (0, common_1.fail)('packageJsonNotFound_0020');
21
+ }
22
+ const { version } = require(data);
23
+ return version;
24
+ });
25
+ }
16
26
  const providers = {
17
27
  none() {
18
28
  return Promise.resolve();
19
29
  },
20
- xcopy(files, args) {
30
+ xcopy(_, files, args) {
21
31
  return __awaiter(this, void 0, void 0, function* () {
22
32
  const { target } = args;
23
33
  if (!target) {
@@ -26,6 +36,28 @@ const providers = {
26
36
  yield Promise.all(files.map((file) => __awaiter(this, void 0, void 0, function* () { return (0, common_1.copy)(file, (0, path_1.resolve)(target, (0, path_1.basename)(file))); })));
27
37
  });
28
38
  },
39
+ feed(directory, files, args, interactive) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const { url, apiKey, scheme = 'basic', version = yield getVersion(directory) } = args;
42
+ if (!url) {
43
+ (0, common_1.fail)('publishFeedMissingUrl_0115');
44
+ }
45
+ if (!version) {
46
+ (0, common_1.fail)('publishFeedMissingVersion_0116');
47
+ }
48
+ const data = {
49
+ version,
50
+ type: 'custom',
51
+ };
52
+ for (const file of files) {
53
+ const relPath = (0, path_1.relative)(file, directory);
54
+ const fileName = (0, path_1.basename)(file);
55
+ const content = yield (0, common_1.readBinary)((0, path_1.dirname)(file), fileName);
56
+ data[relPath] = [content, fileName];
57
+ }
58
+ yield (0, common_1.postForm)(url, scheme, apiKey, data, {}, undefined, interactive);
59
+ });
60
+ },
29
61
  };
30
62
  function findReleaseProvider(providerName) {
31
63
  const provider = providers[providerName];
@@ -42,9 +74,9 @@ function setReleaseProvider(provider) {
42
74
  }
43
75
  }
44
76
  exports.setReleaseProvider = setReleaseProvider;
45
- function publishArtifacts(providerName, files, args) {
77
+ function publishArtifacts(providerName, directory, files, args, interactive) {
46
78
  const runRelease = findReleaseProvider(providerName);
47
- return runRelease(files, args);
79
+ return runRelease(directory, files, args, interactive);
48
80
  }
49
81
  exports.publishArtifacts = publishArtifacts;
50
82
  //# sourceMappingURL=release.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"release.js","sourceRoot":"","sources":["../src/release.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAAyC;AACzC,qCAAsC;AACtC,uCAAsD;AAQtD,MAAM,SAAS,GAAoC;IACjD,IAAI;QACF,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IACK,KAAK,CAAC,KAAK,EAAE,IAAI;;YACrB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;YAExB,I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SAAiB,EACjB,KAAoB,EACpB,IAA4B,EAC5B,WAAoB;IAEpB,MAAM,UAAU,GAAG,mBAAmB,CAAC,YAAY,CAAC,CAAC;IACrD,OAAO,UAAU,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AACzD,CAAC;AATD,4CASC"}
@@ -39,7 +39,7 @@ export interface Bundler {
39
39
  ready(): Promise<void>;
40
40
  }
41
41
  export interface ReleaseProvider {
42
- (files: Array<string>, args: Record<string, string>): Promise<void>;
42
+ (directory: string, files: Array<string>, args: Record<string, string>, interactive: boolean): Promise<void>;
43
43
  }
44
44
  export interface TemplateFileLocation {
45
45
  from: string;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { LogLevels } from './common';
2
+ import type { LogLevels, PiletsInfo } from './common';
3
3
  export interface PackageData {
4
4
  name: string;
5
5
  version: string;
@@ -11,6 +11,14 @@ export interface PackageData {
11
11
  email?: string;
12
12
  };
13
13
  custom?: any;
14
+ pilets?: PiletsInfo;
15
+ piralCLI?: {
16
+ generated: boolean;
17
+ version: string;
18
+ };
19
+ dependencies: Record<string, string>;
20
+ peerDependencies: Record<string, string>;
21
+ devDependencies: Record<string, string>;
14
22
  }
15
23
  export interface PackageFiles {
16
24
  [file: string]: Buffer;
@@ -195,7 +195,7 @@ export declare type PiletPublishSource = 'local' | 'npm' | 'remote';
195
195
  export declare type PiralBuildType = 'all' | 'release' | 'emulator' | 'emulator-sources';
196
196
  export declare type PiletBuildType = 'default' | 'standalone' | 'manifest';
197
197
  export declare type PackageType = 'registry' | 'file' | 'git';
198
- export declare type NpmClientType = 'npm' | 'yarn' | 'pnpm';
198
+ export declare type NpmClientType = 'npm' | 'yarn' | 'pnpm' | 'lerna' | 'rush';
199
199
  export declare type Framework = 'piral-native' | 'piral' | 'piral-core' | 'piral-base';
200
200
  export interface StandardEnvProps {
201
201
  production?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-cli",
3
- "version": "0.15.0-alpha.4122",
3
+ "version": "0.15.0-alpha.4284",
4
4
  "description": "The standard CLI for creating and building a Piral instance or a Pilet.",
5
5
  "keywords": [
6
6
  "portal",
@@ -51,6 +51,7 @@
51
51
  "@types/express": "^4.16.1",
52
52
  "@types/glob": "^7.1.1",
53
53
  "@types/inquirer": "^6.0.0",
54
+ "@types/jju": "^1.4.2",
54
55
  "@types/mime": "^2.0.0",
55
56
  "@types/node": "^12.7.2",
56
57
  "@types/rc": "^1.1.0",
@@ -63,6 +64,7 @@
63
64
  "get-port": "^5.0.0",
64
65
  "glob": "^7.1.3",
65
66
  "inquirer": "^6.2.2",
67
+ "jju": "^1.4.0",
66
68
  "mime": "^2.5.2",
67
69
  "open": "^7.1.0",
68
70
  "rc": "^1.2.8",
@@ -72,11 +74,11 @@
72
74
  "dependencies": {
73
75
  "chalk": "^2.4.2",
74
76
  "dets": "^0.11.1",
75
- "ejs": "^2.6.2",
76
- "kras": "^0.13.2",
77
+ "ejs": "^3.1.7",
78
+ "kras": "^0.14.1",
77
79
  "rimraf": "^3.0.0",
78
80
  "typescript": "^4.0.2",
79
81
  "yargs": "^15.4.1"
80
82
  },
81
- "gitHead": "fa0957fe7dedebbbd97a530e518c1a2b7754d475"
83
+ "gitHead": "c48d6a2c320241d04e3c9c4c4edb423345003587"
82
84
  }
@@ -8,7 +8,6 @@ import {
8
8
  retrievePiletsInfo,
9
9
  config,
10
10
  openBrowser,
11
- reorderInjectors,
12
11
  notifyServerOnline,
13
12
  setLogLevel,
14
13
  progress,
@@ -19,6 +18,9 @@ import {
19
18
  cpuCount,
20
19
  concurrentWorkers,
21
20
  normalizePublicUrl,
21
+ findFile,
22
+ createInitialKrasConfig,
23
+ getAvailablePort,
22
24
  } from '../common';
23
25
 
24
26
  export interface DebugPiletOptions {
@@ -182,9 +184,9 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
182
184
  const {
183
185
  entry = debugPiletDefaults.entry,
184
186
  target = debugPiletDefaults.target,
185
- port = debugPiletDefaults.port,
186
187
  open = debugPiletDefaults.open,
187
188
  hmr = debugPiletDefaults.hmr,
189
+ port: originalPort = debugPiletDefaults.port,
188
190
  publicUrl: originalPublicUrl = debugPiletDefaults.publicUrl,
189
191
  logLevel = debugPiletDefaults.logLevel,
190
192
  concurrency = debugPiletDefaults.concurrency,
@@ -203,7 +205,6 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
203
205
 
204
206
  await hooks.onBegin?.({ options, fullBase });
205
207
  progress('Reading configuration ...');
206
- const krasConfig = readKrasConfig({ port }, krasrc);
207
208
  const api = `${publicUrl}${config.piletApi.replace(/^\/+/, '')}`;
208
209
  const entryList = Array.isArray(entry) ? entry : [entry];
209
210
  const multi = entryList.length > 1 || entryList[0].indexOf('*') !== -1;
@@ -213,10 +214,6 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
213
214
  const maxListeners = Math.max(2 + allEntries.length * 2, 16);
214
215
  log('generalDebug_0003', `Found the following entries: ${allEntries.join(', ')}`);
215
216
 
216
- if (krasConfig.sources === undefined) {
217
- krasConfig.sources = [];
218
- }
219
-
220
217
  if (allEntries.length === 0) {
221
218
  fail('entryFileMissing_0077');
222
219
  }
@@ -234,15 +231,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
234
231
  const dest = resolve(root, target);
235
232
  const outDir = dirname(dest);
236
233
  const outFile = basename(dest);
237
- const exists = await checkExistingDirectory(mocks);
238
-
239
- if (exists) {
240
- if (krasConfig.directory === undefined) {
241
- krasConfig.directory = mocks;
242
- }
243
-
244
- krasConfig.sources.push(mocks);
245
- }
234
+ const mocksExists = await checkExistingDirectory(mocks);
246
235
 
247
236
  await hooks.beforeBuild?.({ root, publicUrl, importmap, entryModule, schemaVersion });
248
237
 
@@ -278,6 +267,7 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
278
267
  externals,
279
268
  piral: appPackage.name,
280
269
  bundler,
270
+ mocks: mocksExists ? mocks : undefined,
281
271
  root,
282
272
  };
283
273
  });
@@ -287,43 +277,33 @@ export async function debugPilet(baseDir = process.cwd(), options: DebugPiletOpt
287
277
 
288
278
  await hooks.beforeApp?.({ appInstanceDir, pilets });
289
279
  const appDir = appInstanceDir || (await getOrMakeAppDir(pilets[0], logLevel));
280
+ const appRoot = dirname(await findFile(appDir, 'package.json'));
290
281
  await hooks.afterApp?.({ appInstanceDir, pilets });
291
282
 
292
283
  Promise.all(pilets.map((p) => p.bundler.ready())).then(() => logDone(`Ready!`));
293
284
 
294
- if (krasConfig.ssl === undefined) {
295
- krasConfig.ssl = undefined;
296
- }
297
-
298
- if (krasConfig.map === undefined) {
299
- krasConfig.map = {};
300
- }
301
-
302
- if (krasConfig.api === undefined) {
303
- krasConfig.api = '/manage-mock-server';
304
- }
305
-
306
- if (krasConfig.injectors === undefined) {
307
- krasConfig.injectors = defaultConfig.injectors;
308
- }
309
-
310
- const { pilet: piletInjector, ...otherInjectors } = krasConfig.injectors;
311
- const injectorConfig = {
312
- meta: 'debug-meta.json',
313
- feed,
314
- ...piletInjector,
315
- active: true,
316
- pilets,
317
- app: appDir,
318
- publicUrl,
319
- handle: ['/', api],
320
- api,
285
+ const sources = pilets.map((m) => m.mocks).filter(Boolean);
286
+ const krasBaseConfig = resolve(fullBase, krasrc);
287
+ const krasRootConfig = resolve(appRoot, krasrc);
288
+ const initial = createInitialKrasConfig(sources[0] || resolve(fullBase, 'mocks'), { [api]: '' }, sources, feed);
289
+ const required = {
290
+ injectors: {
291
+ piral: {
292
+ active: false,
293
+ },
294
+ pilet: {
295
+ active: true,
296
+ pilets,
297
+ app: appDir,
298
+ publicUrl,
299
+ handle: ['/', api],
300
+ api,
301
+ },
302
+ },
321
303
  };
322
-
323
- krasConfig.map['/'] = '';
324
- krasConfig.map[api] = '';
325
-
326
- krasConfig.injectors = reorderInjectors(injectorName, injectorConfig, otherInjectors);
304
+ const configs = [krasBaseConfig, ...pilets.map((p) => resolve(p.root, krasrc)), krasRootConfig];
305
+ const port = await getAvailablePort(originalPort);
306
+ const krasConfig = readKrasConfig({ port, initial, required }, ...configs);
327
307
 
328
308
  log('generalVerbose_0004', `Using kras with configuration: ${JSON.stringify(krasConfig, undefined, 2)}`);
329
309
 
@@ -1,5 +1,5 @@
1
1
  import { dirname, join, resolve } from 'path';
2
- import { readKrasConfig, krasrc, buildKrasWithCli, defaultConfig } from 'kras';
2
+ import { readKrasConfig, krasrc, buildKrasWithCli } from 'kras';
3
3
  import { callPiralDebug } from '../bundler';
4
4
  import { LogLevels } from '../types';
5
5
  import {
@@ -7,7 +7,6 @@ import {
7
7
  retrievePiralRoot,
8
8
  openBrowser,
9
9
  checkCliCompatibility,
10
- reorderInjectors,
11
10
  notifyServerOnline,
12
11
  setLogLevel,
13
12
  progress,
@@ -16,6 +15,8 @@ import {
16
15
  normalizePublicUrl,
17
16
  logDone,
18
17
  getDestination,
18
+ createInitialKrasConfig,
19
+ getAvailablePort,
19
20
  } from '../common';
20
21
 
21
22
  export interface DebugPiralOptions {
@@ -99,15 +100,13 @@ export const debugPiralDefaults: DebugPiralOptions = {
99
100
  optimizeModules: false,
100
101
  };
101
102
 
102
- const injectorName = resolve(__dirname, '../injectors/piral.js');
103
-
104
103
  export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOptions = {}) {
105
104
  const {
106
105
  entry = debugPiralDefaults.entry,
107
106
  target = debugPiralDefaults.target,
108
- port = debugPiralDefaults.port,
109
107
  open = debugPiralDefaults.open,
110
108
  hmr = debugPiralDefaults.hmr,
109
+ port: originalPort = debugPiralDefaults.port,
111
110
  publicUrl: originalPublicUrl = debugPiralDefaults.publicUrl,
112
111
  logLevel = debugPiralDefaults.logLevel,
113
112
  optimizeModules = debugPiralDefaults.optimizeModules,
@@ -125,30 +124,9 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
125
124
  const entryFiles = await retrievePiralRoot(fullBase, entry);
126
125
  const { externals, name, root, ignored } = await retrievePiletsInfo(entryFiles);
127
126
  const dest = getDestination(entryFiles, resolve(fullBase, target));
128
- const krasConfig = readKrasConfig({ port }, krasrc);
129
127
 
130
128
  await checkCliCompatibility(root);
131
129
 
132
- if (krasConfig.directory === undefined) {
133
- krasConfig.directory = join(dirname(entryFiles), 'mocks');
134
- }
135
-
136
- if (krasConfig.ssl === undefined) {
137
- krasConfig.ssl = undefined;
138
- }
139
-
140
- if (krasConfig.map === undefined) {
141
- krasConfig.map = {};
142
- }
143
-
144
- if (krasConfig.api === undefined) {
145
- krasConfig.api = '/manage-mock-server';
146
- }
147
-
148
- if (krasConfig.injectors === undefined) {
149
- krasConfig.injectors = defaultConfig.injectors;
150
- }
151
-
152
130
  await hooks.beforeBuild?.({ root, publicUrl, externals, entryFiles, name });
153
131
 
154
132
  const bundler = await callPiralDebug(
@@ -174,18 +152,25 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
174
152
  hooks.afterBuild?.({ ...args, root, publicUrl, externals, entryFiles, name, bundler, ...dest });
175
153
  });
176
154
 
177
- const { piral: piralInjector, ...otherInjectors } = krasConfig.injectors;
178
- const injectorConfig = {
179
- ...piralInjector,
180
- feed,
181
- active: true,
182
- handle: ['/'],
183
- publicUrl,
184
- bundler,
155
+ const krasBaseConfig = resolve(fullBase, krasrc);
156
+ const krasRootConfig = resolve(root, krasrc);
157
+ const initial = createInitialKrasConfig(join(dirname(entryFiles), 'mocks'));
158
+ const required = {
159
+ injectors: {
160
+ piral: {
161
+ active: true,
162
+ handle: ['/'],
163
+ feed,
164
+ publicUrl,
165
+ bundler,
166
+ },
167
+ pilet: {
168
+ active: false,
169
+ },
170
+ },
185
171
  };
186
-
187
- krasConfig.map['/'] = '';
188
- krasConfig.injectors = reorderInjectors(injectorName, injectorConfig, otherInjectors);
172
+ const port = await getAvailablePort(originalPort);
173
+ const krasConfig = readKrasConfig({ port, initial, required }, krasBaseConfig, krasRootConfig);
189
174
 
190
175
  log('generalVerbose_0004', `Using kras with configuration: ${JSON.stringify(krasConfig, undefined, 2)}`);
191
176
 
@@ -5,12 +5,12 @@ import {
5
5
  SourceLanguage,
6
6
  createDirectory,
7
7
  createFileIfNotExists,
8
- installPackage,
8
+ installNpmPackage,
9
9
  dissectPackageName,
10
10
  copyPiralFiles,
11
11
  patchPiletPackage,
12
12
  scaffoldPiletSourceFiles,
13
- installDependencies,
13
+ installNpmDependencies,
14
14
  combinePackageRef,
15
15
  getPackageName,
16
16
  getPackageVersion,
@@ -27,10 +27,9 @@ import {
27
27
  isLinkedPackage,
28
28
  copyScaffoldingFiles,
29
29
  getPiralPath,
30
- detectMonorepo,
31
- bootstrapMonorepo,
32
30
  getPiletScaffoldData,
33
31
  config,
32
+ initNpmProject,
34
33
  } from '../common';
35
34
 
36
35
  export interface NewPiletOptions {
@@ -130,6 +129,7 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
130
129
 
131
130
  if (success) {
132
131
  const npmClient = await determineNpmClient(root, options.npmClient);
132
+ const projectName = basename(root);
133
133
 
134
134
  progress(`Scaffolding new pilet in %s ...`, root);
135
135
 
@@ -138,7 +138,7 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
138
138
  'package.json',
139
139
  JSON.stringify(
140
140
  {
141
- name: basename(root),
141
+ name: projectName,
142
142
  version: '1.0.0',
143
143
  description: '',
144
144
  keywords: ['pilet'],
@@ -154,6 +154,8 @@ export async function newPilet(baseDir = process.cwd(), options: NewPiletOptions
154
154
  ),
155
155
  );
156
156
 
157
+ await initNpmProject(npmClient, projectName, root);
158
+
157
159
  if (registry !== newPiletDefaults.registry) {
158
160
  progress(`Setting up npm registry (%s) ...`, registry);
159
161
 
@@ -172,8 +174,7 @@ always-auth=true`,
172
174
  const packageRef = combinePackageRef(sourceName, sourceVersion, type);
173
175
 
174
176
  progress(`Installing npm package %s ...`, packageRef);
175
-
176
- await installPackage(npmClient, packageRef, root, '--save-dev', '--save-exact');
177
+ await installNpmPackage(npmClient, packageRef, root, '--save-dev', '--save-exact');
177
178
  } else {
178
179
  progress(`Using locally available npm package %s ...`, sourceName);
179
180
  }
@@ -215,13 +216,7 @@ always-auth=true`,
215
216
 
216
217
  if (install) {
217
218
  progress(`Installing dependencies ...`);
218
- const monorepoKind = await detectMonorepo(root);
219
-
220
- if (monorepoKind === 'lerna') {
221
- await bootstrapMonorepo(root);
222
- } else {
223
- await installDependencies(npmClient, root);
224
- }
219
+ await installNpmDependencies(npmClient, root);
225
220
  }
226
221
 
227
222
  if (postScaffold) {
@@ -1,16 +1,17 @@
1
1
  import { resolve, basename } from 'path';
2
+ import { frameworkKeys } from '../helpers';
2
3
  import { LogLevels, Framework, NpmClientType } from '../types';
3
4
  import {
4
5
  ForceOverwrite,
5
6
  SourceLanguage,
6
- installPackage,
7
+ installNpmPackage,
7
8
  updateExistingJson,
8
9
  getPiralPackage,
9
10
  scaffoldPiralSourceFiles,
10
11
  createDirectory,
11
12
  createFileIfNotExists,
12
13
  logDone,
13
- installDependencies,
14
+ installNpmDependencies,
14
15
  combinePackageRef,
15
16
  setLogLevel,
16
17
  fail,
@@ -19,7 +20,9 @@ import {
19
20
  cliVersion,
20
21
  getPiralScaffoldData,
21
22
  config,
23
+ initNpmProject,
22
24
  } from '../common';
25
+ import { sourceLanguageKeys } from '..';
23
26
 
24
27
  export interface NewPiralOptions {
25
28
  /**
@@ -121,6 +124,11 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
121
124
  } = options;
122
125
  const fullBase = resolve(process.cwd(), baseDir);
123
126
  const root = resolve(fullBase, target);
127
+
128
+ if (!frameworkKeys.includes(framework)) {
129
+ fail('generalError_0002', `The "framework" value must be one of: ${frameworkKeys.join(', ')}`);
130
+ }
131
+
124
132
  setLogLevel(logLevel);
125
133
  progress('Preparing source and target ...');
126
134
  const success = await createDirectory(root);
@@ -128,6 +136,7 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
128
136
  if (success) {
129
137
  const npmClient = await determineNpmClient(root, options.npmClient);
130
138
  const packageRef = combinePackageRef(framework, version, 'registry');
139
+ const projectName = basename(root);
131
140
 
132
141
  progress(`Creating a new Piral instance in %s ...`, root);
133
142
 
@@ -136,7 +145,7 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
136
145
  'package.json',
137
146
  JSON.stringify(
138
147
  {
139
- name: basename(root),
148
+ name: projectName,
140
149
  version: '1.0.0',
141
150
  description: '',
142
151
  keywords: ['piral'],
@@ -148,6 +157,8 @@ export async function newPiral(baseDir = process.cwd(), options: NewPiralOptions
148
157
  ),
149
158
  );
150
159
 
160
+ await initNpmProject(npmClient, projectName, root);
161
+
151
162
  if (registry !== newPiralDefaults.registry) {
152
163
  progress(`Setting up npm registry (%s) ...`, registry);
153
164
 
@@ -162,7 +173,7 @@ always-auth=true`,
162
173
 
163
174
  progress(`Installing npm package ${packageRef} ...`);
164
175
 
165
- await installPackage(npmClient, packageRef, root, '--save-exact');
176
+ await installNpmPackage(npmClient, packageRef, root, '--save-exact');
166
177
 
167
178
  progress(`Taking care of templating ...`);
168
179
 
@@ -177,7 +188,7 @@ always-auth=true`,
177
188
 
178
189
  if (install) {
179
190
  progress(`Installing dependencies ...`);
180
- await installDependencies(npmClient, root);
191
+ await installNpmDependencies(npmClient, root);
181
192
  }
182
193
 
183
194
  logDone(`Piral instance scaffolded successfully!`);
@@ -13,7 +13,7 @@ import {
13
13
  log,
14
14
  config,
15
15
  checkExists,
16
- findTarball,
16
+ findNpmTarball,
17
17
  downloadFile,
18
18
  matchAnyPilet,
19
19
  retrievePiletData,
@@ -77,6 +77,11 @@ export interface PublishPiletOptions {
77
77
  */
78
78
  headers?: Record<string, string>;
79
79
 
80
+ /**
81
+ * Defines if authorization tokens can be retrieved interactively.
82
+ */
83
+ interactive?: boolean;
84
+
80
85
  /**
81
86
  * Sets the bundler to use for building, if any specific.
82
87
  */
@@ -104,6 +109,7 @@ export const publishPiletDefaults: PublishPiletOptions = {
104
109
  from: 'local',
105
110
  fields: {},
106
111
  headers: {},
112
+ interactive: false,
107
113
  };
108
114
 
109
115
  async function getFiles(
@@ -192,7 +198,7 @@ async function getFiles(
192
198
  }
193
199
  case 'npm': {
194
200
  log('generalDebug_0003', `View npm package "${sources.join('", "')}".`);
195
- const allUrls = await Promise.all(sources.map((s) => findTarball(s)));
201
+ const allUrls = await Promise.all(sources.map((s) => findNpmTarball(s)));
196
202
  log('generalDebug_0003', `Download file from "${allUrls.join('", "')}".`);
197
203
  const allFiles = await Promise.all(allUrls.map((url) => downloadFile(url, ca)));
198
204
  return allFiles.reduce((result, files) => [...result, ...files], []);
@@ -214,6 +220,7 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
214
220
  fields = publishPiletDefaults.fields,
215
221
  headers = publishPiletDefaults.headers,
216
222
  mode = publishPiletDefaults.mode,
223
+ interactive = publishPiletDefaults.interactive,
217
224
  _ = {},
218
225
  bundlerName,
219
226
  } = options;
@@ -254,7 +261,7 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
254
261
 
255
262
  if (content) {
256
263
  progress(`Publishing "%s" ...`, file, url);
257
- const result = await postFile(url, mode, apiKey, content, fields, headers, ca);
264
+ const result = await postFile(url, mode, apiKey, content, fields, headers, ca, interactive);
258
265
 
259
266
  if (result.success) {
260
267
  successfulUploads.push(file);