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.
Files changed (162) hide show
  1. package/lib/apps/build-pilet.js.map +1 -1
  2. package/lib/apps/build-piral.js.map +1 -1
  3. package/lib/apps/debug-pilet.js.map +1 -1
  4. package/lib/apps/debug-piral.js.map +1 -1
  5. package/lib/apps/index.js +5 -1
  6. package/lib/apps/index.js.map +1 -1
  7. package/lib/apps/new-pilet.js +5 -9
  8. package/lib/apps/new-pilet.js.map +1 -1
  9. package/lib/apps/new-piral.js +5 -3
  10. package/lib/apps/new-piral.js.map +1 -1
  11. package/lib/apps/publish-pilet.d.ts +4 -0
  12. package/lib/apps/publish-pilet.js +4 -3
  13. package/lib/apps/publish-pilet.js.map +1 -1
  14. package/lib/apps/publish-piral.d.ts +4 -0
  15. package/lib/apps/publish-piral.js +9 -7
  16. package/lib/apps/publish-piral.js.map +1 -1
  17. package/lib/apps/upgrade-pilet.js +2 -8
  18. package/lib/apps/upgrade-pilet.js.map +1 -1
  19. package/lib/apps/upgrade-piral.js +1 -1
  20. package/lib/apps/upgrade-piral.js.map +1 -1
  21. package/lib/build/bundler-calls.d.ts +1 -1
  22. package/lib/build/run-build-pilet.js.map +1 -1
  23. package/lib/build/run-build-piral.js.map +1 -1
  24. package/lib/build/run-debug-mono-piral.js +1 -1
  25. package/lib/build/run-debug-mono-piral.js.map +1 -1
  26. package/lib/build/run-debug-pilet.js.map +1 -1
  27. package/lib/build/run-debug-piral.js.map +1 -1
  28. package/lib/bundler.js +1 -1
  29. package/lib/bundler.js.map +1 -1
  30. package/lib/commands.js +8 -0
  31. package/lib/commands.js.map +1 -1
  32. package/lib/common/browser.d.ts +1 -0
  33. package/lib/common/browser.js +16 -10
  34. package/lib/common/browser.js.map +1 -1
  35. package/lib/common/clients/index.d.ts +19 -0
  36. package/lib/common/clients/index.js +40 -0
  37. package/lib/common/clients/index.js.map +1 -0
  38. package/lib/common/clients/lerna.d.ts +6 -1
  39. package/lib/common/clients/lerna.js +67 -3
  40. package/lib/common/clients/lerna.js.map +1 -1
  41. package/lib/common/clients/npm.d.ts +4 -1
  42. package/lib/common/clients/npm.js +36 -9
  43. package/lib/common/clients/npm.js.map +1 -1
  44. package/lib/common/clients/pnpm.d.ts +4 -0
  45. package/lib/common/clients/pnpm.js +41 -1
  46. package/lib/common/clients/pnpm.js.map +1 -1
  47. package/lib/common/clients/rush.d.ts +6 -0
  48. package/lib/common/clients/rush.js +118 -0
  49. package/lib/common/clients/rush.js.map +1 -0
  50. package/lib/common/clients/yarn.d.ts +4 -0
  51. package/lib/common/clients/yarn.js +44 -4
  52. package/lib/common/clients/yarn.js.map +1 -1
  53. package/lib/common/config.js.map +1 -1
  54. package/lib/common/constants.d.ts +1 -1
  55. package/lib/common/constants.js +1 -1
  56. package/lib/common/constants.js.map +1 -1
  57. package/lib/common/declaration.js +14 -10
  58. package/lib/common/declaration.js.map +1 -1
  59. package/lib/common/emulator.js +2 -2
  60. package/lib/common/emulator.js.map +1 -1
  61. package/lib/common/http.d.ts +1 -1
  62. package/lib/common/http.js +12 -7
  63. package/lib/common/http.js.map +1 -1
  64. package/lib/common/importmap.js +7 -16
  65. package/lib/common/importmap.js.map +1 -1
  66. package/lib/common/index.js +5 -1
  67. package/lib/common/index.js.map +1 -1
  68. package/lib/common/info.d.ts +4 -0
  69. package/lib/common/info.js +6 -1
  70. package/lib/common/info.js.map +1 -1
  71. package/lib/common/inspect.js +2 -1
  72. package/lib/common/inspect.js.map +1 -1
  73. package/lib/common/interactive.d.ts +9 -0
  74. package/lib/common/interactive.js +31 -1
  75. package/lib/common/interactive.js.map +1 -1
  76. package/lib/common/io.js +1 -1
  77. package/lib/common/io.js.map +1 -1
  78. package/lib/common/npm.d.ts +11 -16
  79. package/lib/common/npm.js +165 -158
  80. package/lib/common/npm.js.map +1 -1
  81. package/lib/common/pack.js +1 -1
  82. package/lib/common/pack.js.map +1 -1
  83. package/lib/common/package.d.ts +6 -7
  84. package/lib/common/package.js +26 -28
  85. package/lib/common/package.js.map +1 -1
  86. package/lib/common/scaffold.js +5 -2
  87. package/lib/common/scaffold.js.map +1 -1
  88. package/lib/common/version.js +4 -4
  89. package/lib/common/version.js.map +1 -1
  90. package/lib/external/index.js +2380 -470
  91. package/lib/helpers.d.ts +1 -1
  92. package/lib/helpers.js +1 -1
  93. package/lib/helpers.js.map +1 -1
  94. package/lib/index.js +5 -1
  95. package/lib/index.js.map +1 -1
  96. package/lib/injectors/pilet.d.ts +1 -0
  97. package/lib/injectors/pilet.js +7 -7
  98. package/lib/injectors/pilet.js.map +1 -1
  99. package/lib/messages.d.ts +1 -1
  100. package/lib/messages.js +5 -1
  101. package/lib/messages.js.map +1 -1
  102. package/lib/plugin.js +27 -2
  103. package/lib/plugin.js.map +1 -1
  104. package/lib/release.d.ts +1 -1
  105. package/lib/release.js +7 -2
  106. package/lib/release.js.map +1 -1
  107. package/lib/types/common.d.ts +1 -1
  108. package/lib/types/index.js +5 -1
  109. package/lib/types/index.js.map +1 -1
  110. package/lib/types/internal.d.ts +9 -1
  111. package/lib/types/public.d.ts +2 -2
  112. package/package.json +5 -3
  113. package/src/apps/new-pilet.ts +9 -14
  114. package/src/apps/new-piral.ts +9 -5
  115. package/src/apps/publish-pilet.ts +10 -3
  116. package/src/apps/publish-piral.ts +21 -6
  117. package/src/apps/upgrade-pilet.ts +4 -12
  118. package/src/apps/upgrade-piral.ts +2 -2
  119. package/src/build/bundler-calls.ts +1 -1
  120. package/src/build/run-build-pilet.ts +1 -1
  121. package/src/build/run-build-piral.ts +1 -1
  122. package/src/build/run-debug-mono-piral.ts +2 -2
  123. package/src/build/run-debug-pilet.ts +1 -1
  124. package/src/build/run-debug-piral.ts +1 -1
  125. package/src/bundler.test.ts +1 -1
  126. package/src/bundler.ts +2 -2
  127. package/src/commands.ts +8 -0
  128. package/src/common/browser.ts +12 -8
  129. package/src/common/clients/index.ts +33 -0
  130. package/src/common/clients/lerna.ts +61 -1
  131. package/src/common/clients/npm.ts +31 -6
  132. package/src/common/clients/pnpm.ts +37 -0
  133. package/src/common/clients/rush.ts +111 -0
  134. package/src/common/clients/yarn.ts +40 -3
  135. package/src/common/config.ts +3 -3
  136. package/src/common/constants.ts +1 -1
  137. package/src/common/declaration.ts +17 -10
  138. package/src/common/emulator.ts +3 -3
  139. package/src/common/http.ts +20 -6
  140. package/src/common/importmap.ts +7 -15
  141. package/src/common/info.ts +6 -1
  142. package/src/common/inspect.ts +2 -1
  143. package/src/common/interactive.test.ts +3 -0
  144. package/src/common/interactive.ts +48 -1
  145. package/src/common/io.ts +1 -1
  146. package/src/common/npm.test.ts +122 -76
  147. package/src/common/npm.ts +177 -152
  148. package/src/common/pack.test.ts +1 -1
  149. package/src/common/pack.ts +2 -2
  150. package/src/common/package.test.ts +1 -14
  151. package/src/common/package.ts +31 -29
  152. package/src/common/scaffold.ts +7 -2
  153. package/src/common/version.ts +4 -4
  154. package/src/external/index.ts +2 -1
  155. package/src/helpers.ts +2 -2
  156. package/src/injectors/pilet.ts +9 -8
  157. package/src/messages.ts +6 -2
  158. package/src/plugin.ts +34 -5
  159. package/src/release.ts +10 -2
  160. package/src/types/common.ts +1 -1
  161. package/src/types/internal.ts +6 -1
  162. package/src/types/public.ts +2 -2
@@ -8,11 +8,12 @@ import { checkAppShellCompatibility } from './compatibility';
8
8
  import { deepMerge } from './merge';
9
9
  import { applyTemplate } from './template';
10
10
  import { readImportmap } from './importmap';
11
- import { isGitPackage, isLocalPackage, makeGitUrl, makeFilePath, makePiletExternals, makeExternals } from './npm';
12
11
  import { filesTar, filesOnceTar, declarationEntryExtensions, bundlerNames } from './constants';
13
12
  import { getHash, checkIsDirectory, matchFiles } from './io';
14
13
  import { readJson, copy, updateExistingJson, findFile, checkExists } from './io';
15
- import { Framework, FileInfo, PiletsInfo, TemplateFileLocation } from '../types';
14
+ import { isGitPackage, isLocalPackage, makeGitUrl, makeFilePath } from './npm';
15
+ import { makePiletExternals, makeExternals, findPackageRoot } from './npm';
16
+ import { Framework, FileInfo, PiletsInfo, TemplateFileLocation, PackageData } from '../types';
16
17
 
17
18
  function appendBundler(devDependencies: Record<string, string>, bundler: string, version: string) {
18
19
  if (bundler && bundler !== 'none') {
@@ -113,26 +114,13 @@ async function getMatchingFiles(
113
114
  }
114
115
 
115
116
  export function getPiralPath(root: string, name: string) {
116
- try {
117
- const path = require.resolve(`${name}/package.json`, {
118
- paths: [root],
119
- });
120
- return dirname(path);
121
- } catch (ex) {
122
- log('generalDebug_0003', `Could not resolve the Piral path of "${name}" in "${root}": ${ex}.`);
117
+ const path = findPackageRoot(name, root);
118
+
119
+ if (!path) {
123
120
  fail('invalidPiralReference_0043');
124
121
  }
125
- }
126
122
 
127
- export function findPackageRoot(pck: string, baseDir: string) {
128
- try {
129
- return require.resolve(`${pck}/package.json`, {
130
- paths: [baseDir],
131
- });
132
- } catch (ex) {
133
- log('generalDebug_0003', `Could not find the package root in "${baseDir}": ${ex}.`);
134
- return undefined;
135
- }
123
+ return dirname(path);
136
124
  }
137
125
 
138
126
  function findPackage(pck: string | Array<string>, baseDir: string) {
@@ -161,7 +149,7 @@ function findPackage(pck: string | Array<string>, baseDir: string) {
161
149
  return undefined;
162
150
  }
163
151
 
164
- export function readPiralPackage(root: string, name: string) {
152
+ export function readPiralPackage(root: string, name: string): Promise<PackageData> {
165
153
  log('generalDebug_0003', `Reading the piral package in "${root}" ...`);
166
154
  const path = getPiralPath(root, name);
167
155
  return readJson(path, 'package.json');
@@ -196,7 +184,12 @@ export function getPiralPackage(
196
184
  },
197
185
  importmap: {
198
186
  imports: {},
199
- inherit: ['piral-base', framework !== 'piral-base' && 'piral-core'].filter(Boolean),
187
+ inherit: [
188
+ 'piral-base', // this we take in any case
189
+ framework !== 'piral-base' && 'piral-core', // this we take unless we selected piral-base, then obviously core is not invited to the party
190
+ framework === 'piral' && 'piral', // this we take only if we selected piral
191
+ framework === 'piral-native' && 'piral-native', // this we also only take if we selected piral-native
192
+ ].filter(Boolean),
200
193
  },
201
194
  pilets: getPiletsInfo({}),
202
195
  dependencies,
@@ -325,10 +318,19 @@ function isTemplateFileLocation(item: string | TemplateFileLocation): item is Te
325
318
  return typeof item === 'object';
326
319
  }
327
320
 
321
+ function tryFindPackageVersion(packageName: string): string {
322
+ try {
323
+ const { version } = require(`${packageName}/package.json`);
324
+ return version;
325
+ } catch {
326
+ return undefined;
327
+ }
328
+ }
329
+
328
330
  export async function copyPiralFiles(
329
331
  root: string,
330
332
  name: string,
331
- piralInfo: any,
333
+ piralInfo: PackageData,
332
334
  forceOverwrite: ForceOverwrite,
333
335
  variables: Record<string, string>,
334
336
  originalFiles?: Array<FileInfo>,
@@ -348,7 +350,7 @@ export async function copyPiralFiles(
348
350
  await copyFiles(files, forceOverwrite, originalFiles, variables);
349
351
  }
350
352
 
351
- export function getPiletsInfo(piralInfo: any): PiletsInfo {
353
+ export function getPiletsInfo(piralInfo: Partial<PackageData>): PiletsInfo {
352
354
  const {
353
355
  files = [],
354
356
  scripts = {},
@@ -457,7 +459,7 @@ export async function retrieveExternals(root: string, packageInfo: any) {
457
459
  ...packageInfo.dependencies,
458
460
  };
459
461
  const deps = packageInfo.pilets?.externals;
460
- return makeExternals(allDeps, deps);
462
+ return makeExternals(root, allDeps, deps);
461
463
  }
462
464
 
463
465
  return sharedDependencies.map((m) => m.name);
@@ -476,9 +478,9 @@ export async function retrievePiletsInfo(entryFile: string) {
476
478
  fail('packageJsonMissing_0074');
477
479
  }
478
480
 
481
+ const root = dirname(packageJson);
479
482
  const packageInfo = require(packageJson);
480
483
  const info = getPiletsInfo(packageInfo);
481
- const root = dirname(packageJson);
482
484
  const externals = await retrieveExternals(root, packageInfo);
483
485
 
484
486
  return {
@@ -507,7 +509,7 @@ export async function patchPiletPackage(
507
509
  root: string,
508
510
  name: string,
509
511
  version: string,
510
- piralInfo: any,
512
+ piralInfo: PackageData,
511
513
  fromEmulator: boolean,
512
514
  newInfo?: { language: SourceLanguage; bundler: string },
513
515
  ) {
@@ -531,7 +533,7 @@ export async function patchPiletPackage(
531
533
  }
532
534
  : info.scripts;
533
535
  const peerModules = [];
534
- const allExternals = makePiletExternals(piralDependencies, externals, fromEmulator, piralInfo);
536
+ const allExternals = makePiletExternals(root, piralDependencies, externals, fromEmulator, piralInfo);
535
537
  const peerDependencies = {
536
538
  ...allExternals.reduce((deps, name) => {
537
539
  const valid = isValidDependency(name);
@@ -555,7 +557,7 @@ export async function patchPiletPackage(
555
557
  return deps;
556
558
  }, {}),
557
559
  ...allExternals.filter(isValidDependency).reduce((deps, name) => {
558
- const version = piralDependencies[name];
560
+ const version = piralDependencies[name] || tryFindPackageVersion(name);
559
561
 
560
562
  if (version || newInfo) {
561
563
  // set only if we have an explicit version or we are in the scaffolding case
@@ -592,7 +594,7 @@ export async function patchPiletPackage(
592
594
  /**
593
595
  * Returns true if its an emulator package, otherwise it has to be a "raw" app shell.
594
596
  */
595
- export function checkAppShellPackage(appPackage: any) {
597
+ export function checkAppShellPackage(appPackage: PackageData) {
596
598
  const { piralCLI = { generated: false, version: cliVersion } } = appPackage;
597
599
 
598
600
  if (piralCLI.generated) {
@@ -1,5 +1,5 @@
1
1
  import { join, dirname, resolve, basename, isAbsolute } from 'path';
2
- import { installPackage } from './clients/npm';
2
+ import { installNpmPackage } from './npm';
3
3
  import { ForceOverwrite, SourceLanguage } from './enums';
4
4
  import { createDirectory, createFileIfNotExists, updateExistingJson } from './io';
5
5
  import { cliVersion, isWindows } from './info';
@@ -37,8 +37,13 @@ async function getTemplateFiles(
37
37
  if (templatePackageName.startsWith('.')) {
38
38
  templatePackageName = resolve(process.cwd(), templatePackageName);
39
39
  } else {
40
- await installPackage(templatePackageName, __dirname, '--registry', registry);
40
+ if (templatePackageName.indexOf('@', 1) === -1) {
41
+ templatePackageName = `${templatePackageName}@latest`;
42
+ }
43
+
44
+ await installNpmPackage('npm', templatePackageName, __dirname, '--registry', registry);
41
45
  }
46
+
42
47
  const templateRunner = getTemplatePackage(templatePackageName);
43
48
  const logLevel = getLogLevel();
44
49
  const details = {
@@ -16,15 +16,15 @@ function indexOrEnd(str: string, q: string) {
16
16
  }
17
17
 
18
18
  function splitVersion(v: string) {
19
- var c = v.replace(/^v/, '').replace(/\+.*$/, '');
20
- var patchIndex = indexOrEnd(c, '-');
21
- var arr = c.substring(0, patchIndex).split('.');
19
+ const c = v.replace(/^v/, '').replace(/\+.*$/, '');
20
+ const patchIndex = indexOrEnd(c, '-');
21
+ const arr = c.substring(0, patchIndex).split('.');
22
22
  arr.push(c.substring(patchIndex + 1));
23
23
  return arr;
24
24
  }
25
25
 
26
26
  function parseSegment(v: string) {
27
- var n = parseInt(v, 10);
27
+ const n = parseInt(v, 10);
28
28
  return isNaN(n) ? v : n;
29
29
  }
30
30
 
@@ -1,6 +1,7 @@
1
1
  import logger = require('@parcel/logger');
2
2
  import stripAnsi = require('strip-ansi');
3
3
  import inquirer = require('inquirer');
4
+ import jju = require('jju');
4
5
  import glob = require('glob');
5
6
  import tar = require('tar');
6
7
  import FormData = require('form-data');
@@ -10,4 +11,4 @@ import mime = require('mime');
10
11
  import getPort = require('get-port');
11
12
  import open = require('open');
12
13
 
13
- export { logger, inquirer, glob, tar, FormData, rc, axios, mime, stripAnsi, getPort, open };
14
+ export { logger, inquirer, glob, tar, FormData, rc, axios, mime, stripAnsi, getPort, open, jju };
package/src/helpers.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ForceOverwrite, SourceLanguage } from './common/enums';
2
2
  import { bundlerNames, frameworkLibs } from './common/constants';
3
- import {
3
+ import type {
4
4
  Framework,
5
5
  NpmClientType,
6
6
  PiletSchemaVersion,
@@ -15,7 +15,7 @@ export const publishModeKeys: Array<PiletPublishScheme> = ['none', 'basic', 'bea
15
15
  export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
16
16
  export const piralBuildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
17
17
  export const piletBuildTypeKeys: Array<PiletBuildType> = ['default', 'standalone', 'manifest'];
18
- export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'yarn'];
18
+ export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'yarn', 'lerna', 'rush'];
19
19
  export const bundlerKeys: Array<string> = ['none', ...bundlerNames];
20
20
  export const availableBundlers: Array<string> = [];
21
21
  export const availableReleaseProviders: Array<string> = [];
@@ -6,11 +6,10 @@ import { KrasInjector, KrasResponse, KrasRequest, KrasInjectorConfig, KrasConfig
6
6
  import { log } from '../common/log';
7
7
  import { getPiletSpecMeta } from '../common/spec';
8
8
  import { config } from '../common/config';
9
- import { axios, mime } from '../external';
9
+ import { axios, mime, jju } from '../external';
10
10
  import { Bundler } from '../types';
11
11
 
12
12
  const { host } = config;
13
- const indexPath = '/index.html';
14
13
 
15
14
  interface Pilet {
16
15
  bundler: Bundler;
@@ -36,8 +35,8 @@ function fillPiletMeta(pilet: Pilet, basePath: string, metaFile: string) {
36
35
  const { root, bundler } = pilet;
37
36
  const metaPath = join(root, metaFile);
38
37
  const packagePath = join(root, 'package.json');
39
- const def = JSON.parse(readFileSync(packagePath, 'utf8'));
40
- const metaOverride = existsSync(metaPath) ? JSON.parse(readFileSync(metaPath, 'utf8')) : undefined;
38
+ const def = jju.parse(readFileSync(packagePath, 'utf8'));
39
+ const metaOverride = existsSync(metaPath) ? jju.parse(readFileSync(metaPath, 'utf8')) : undefined;
41
40
  const file = bundler.bundle.name.replace(/^[\/\\]/, '');
42
41
  const target = join(bundler.bundle.dir, file);
43
42
  const url = new URL(file, basePath);
@@ -76,6 +75,7 @@ async function loadFeed(feed: string) {
76
75
  export default class PiletInjector implements KrasInjector {
77
76
  public config: PiletInjectorConfig;
78
77
  private piletApi: string;
78
+ private indexPath: string;
79
79
 
80
80
  constructor(options: PiletInjectorConfig, config: KrasConfiguration, core: EventEmitter) {
81
81
  this.config = options;
@@ -84,7 +84,8 @@ export default class PiletInjector implements KrasInjector {
84
84
  ? options.api
85
85
  : `${config.ssl ? 'https' : 'http'}://${host}:${config.port}${options.api}`;
86
86
 
87
- const { pilets, api } = options;
87
+ const { pilets, api, publicUrl } = options;
88
+ this.indexPath = `${publicUrl}index.html`;
88
89
  const cbs = {};
89
90
 
90
91
  core.on('user-connected', (e) => {
@@ -220,15 +221,15 @@ export default class PiletInjector implements KrasInjector {
220
221
  const target = join(app, path);
221
222
 
222
223
  if (existsSync(target) && statSync(target).isFile()) {
223
- if (req.url === indexPath) {
224
+ if (req.url === this.indexPath) {
224
225
  return this.sendIndexFile(target, req.url);
225
226
  } else {
226
227
  return this.sendFile(target, req.url);
227
228
  }
228
- } else if (req.url !== indexPath) {
229
+ } else if (req.url !== this.indexPath) {
229
230
  return this.handle({
230
231
  ...req,
231
- url: indexPath,
232
+ url: this.indexPath,
232
233
  });
233
234
  }
234
235
  }
package/src/messages.ts CHANGED
@@ -549,7 +549,11 @@ export function importMapVersionSpecInvalid_0026(depName: string): QuickMessage
549
549
  * node modules are most likely not installed (correctly).
550
550
  */
551
551
  export function importMapReferenceNotFound_0027(dir: string, reference: string): QuickMessage {
552
- return [LogLevels.error, '0027', `The reference to "${reference}" could not be resolved from "${dir}". Are you sure the file or package exists?`];
552
+ return [
553
+ LogLevels.error,
554
+ '0027',
555
+ `The reference to "${reference}" could not be resolved from "${dir}". Are you sure the file or package exists?`,
556
+ ];
553
557
  }
554
558
 
555
559
  /**
@@ -1842,7 +1846,7 @@ export function packageJsonMissing_0075(): QuickMessage {
1842
1846
  * The TypeScript declaration generator will take all files as input to
1843
1847
  * gather all required information for constructing the API declaration.
1844
1848
  */
1845
- export function declarationCouldNotBeGenerated_0076(rootDir: string, error: Error): QuickMessage {
1849
+ export function declarationCouldNotBeGenerated_0076(rootDir: string, error: Error | string): QuickMessage {
1846
1850
  return [LogLevels.error, '0076', `Could not create the declaration in "${rootDir}". Error: ${error}`];
1847
1851
  }
1848
1852
 
package/src/plugin.ts CHANGED
@@ -1,10 +1,39 @@
1
1
  import { readdir, stat } from 'fs';
2
- import { join, resolve } from 'path';
3
- import { log } from './common';
2
+ import { join, resolve, sep, posix } from 'path';
3
+ import { cliName, cliVersion, log } from './common';
4
4
  import { inject } from './inject';
5
5
 
6
- function getLocalPackageDir() {
7
- return resolve(__dirname, '..', '..');
6
+ function getContainerDir() {
7
+ const currentDir = __dirname.split(sep).join(posix.sep);
8
+
9
+ if (!currentDir.includes(`/.pnpm/${cliName}@${cliVersion}/node_modules/${cliName}/`)) {
10
+ return resolve(__dirname, '..', '..');
11
+ }
12
+
13
+ return undefined;
14
+ }
15
+
16
+ async function getLocalPackageDir() {
17
+ const proposedDirs = [
18
+ getContainerDir(),
19
+ resolve(process.cwd(), 'node_modules'),
20
+ resolve(process.cwd(), '..', 'node_modules'),
21
+ resolve(process.cwd(), '..', '..', 'node_modules'),
22
+ resolve(process.cwd(), '..', '..', '..', 'node_modules'),
23
+ ];
24
+
25
+ // Right now we always take the first one, but in the future this may be different
26
+ // once we come up with more / better criteria to identify if its a good/valid
27
+ // plugin root directory
28
+ for (const dir of proposedDirs.filter(Boolean)) {
29
+ log('generalDebug_0003', `Checking for potential plugin directory "${dir}" ...`);
30
+
31
+ if (await isDirectory(dir)) {
32
+ return dir;
33
+ }
34
+ }
35
+
36
+ return undefined;
8
37
  }
9
38
 
10
39
  function isDirectory(dir: string) {
@@ -83,7 +112,7 @@ async function getAllPlugins(rootDir: string): Promise<Array<string>> {
83
112
  }
84
113
 
85
114
  export async function loadPlugins() {
86
- const localDir = getLocalPackageDir();
115
+ const localDir = await getLocalPackageDir();
87
116
  const allPlugins = await getAllPlugins(localDir);
88
117
 
89
118
  for (const pluginPath of allPlugins) {
package/src/release.ts CHANGED
@@ -21,6 +21,9 @@ const providers: Record<string, ReleaseProvider> = {
21
21
 
22
22
  await Promise.all(files.map(async (file) => copy(file, resolve(target, basename(file)))));
23
23
  },
24
+ async feed(files, args, interactive) {
25
+ //TODO post files to Piral Feed Service
26
+ },
24
27
  };
25
28
 
26
29
  function findReleaseProvider(providerName: string) {
@@ -43,7 +46,12 @@ export function setReleaseProvider(provider: QualifiedReleaseProvider) {
43
46
  }
44
47
  }
45
48
 
46
- export function publishArtifacts(providerName: string, files: Array<string>, args: Record<string, string>) {
49
+ export function publishArtifacts(
50
+ providerName: string,
51
+ files: Array<string>,
52
+ args: Record<string, string>,
53
+ interactive: boolean,
54
+ ) {
47
55
  const runRelease = findReleaseProvider(providerName);
48
- return runRelease(files, args);
56
+ return runRelease(files, args, interactive);
49
57
  }
@@ -42,7 +42,7 @@ export interface Bundler {
42
42
  }
43
43
 
44
44
  export interface ReleaseProvider {
45
- (files: Array<string>, args: Record<string, string>): Promise<void>;
45
+ (files: Array<string>, args: Record<string, string>, interactive: boolean): Promise<void>;
46
46
  }
47
47
 
48
48
  export interface TemplateFileLocation {
@@ -1,4 +1,4 @@
1
- import { LogLevels } from './common';
1
+ import type { LogLevels, PiletsInfo } from './common';
2
2
 
3
3
  export interface PackageData {
4
4
  name: string;
@@ -13,6 +13,11 @@ export interface PackageData {
13
13
  email?: string;
14
14
  };
15
15
  custom?: any;
16
+ pilets?: PiletsInfo;
17
+ piralCLI?: { generated: boolean; version: string };
18
+ dependencies: Record<string, string>;
19
+ peerDependencies: Record<string, string>;
20
+ devDependencies: Record<string, string>;
16
21
  }
17
22
 
18
23
  export interface PackageFiles {
@@ -229,9 +229,9 @@ export type PiletBuildType = 'default' | 'standalone' | 'manifest';
229
229
 
230
230
  export type PackageType = 'registry' | 'file' | 'git';
231
231
 
232
- export type NpmClientType = 'npm' | 'yarn' | 'pnpm';
232
+ export type NpmClientType = 'npm' | 'yarn' | 'pnpm' | 'lerna' | 'rush';
233
233
 
234
- export type Framework = 'piral' | 'piral-core' | 'piral-base';
234
+ export type Framework = 'piral-native' | 'piral' | 'piral-core' | 'piral-base';
235
235
 
236
236
  export interface StandardEnvProps {
237
237
  production?: boolean;