piral-cli 0.14.24-beta.4161 → 0.14.24-beta.4171

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 (84) hide show
  1. package/lib/apps/new-pilet.js +5 -9
  2. package/lib/apps/new-pilet.js.map +1 -1
  3. package/lib/apps/new-piral.js +5 -3
  4. package/lib/apps/new-piral.js.map +1 -1
  5. package/lib/apps/publish-pilet.js +1 -1
  6. package/lib/apps/publish-pilet.js.map +1 -1
  7. package/lib/apps/publish-piral.js +1 -1
  8. package/lib/apps/publish-piral.js.map +1 -1
  9. package/lib/apps/upgrade-pilet.js +2 -8
  10. package/lib/apps/upgrade-pilet.js.map +1 -1
  11. package/lib/apps/upgrade-piral.js +1 -1
  12. package/lib/apps/upgrade-piral.js.map +1 -1
  13. package/lib/bundler.js +1 -1
  14. package/lib/bundler.js.map +1 -1
  15. package/lib/common/clients/index.d.ts +19 -0
  16. package/lib/common/clients/index.js +40 -0
  17. package/lib/common/clients/index.js.map +1 -0
  18. package/lib/common/clients/lerna.d.ts +4 -1
  19. package/lib/common/clients/lerna.js +40 -3
  20. package/lib/common/clients/lerna.js.map +1 -1
  21. package/lib/common/clients/npm.d.ts +3 -1
  22. package/lib/common/clients/npm.js +24 -16
  23. package/lib/common/clients/npm.js.map +1 -1
  24. package/lib/common/clients/pnpm.d.ts +2 -0
  25. package/lib/common/clients/pnpm.js +18 -11
  26. package/lib/common/clients/pnpm.js.map +1 -1
  27. package/lib/common/clients/rush.d.ts +4 -0
  28. package/lib/common/clients/rush.js +91 -0
  29. package/lib/common/clients/rush.js.map +1 -0
  30. package/lib/common/clients/yarn.d.ts +2 -0
  31. package/lib/common/clients/yarn.js +20 -13
  32. package/lib/common/clients/yarn.js.map +1 -1
  33. package/lib/common/emulator.js +1 -1
  34. package/lib/common/emulator.js.map +1 -1
  35. package/lib/common/inspect.js +2 -1
  36. package/lib/common/inspect.js.map +1 -1
  37. package/lib/common/npm.d.ts +7 -15
  38. package/lib/common/npm.js +69 -127
  39. package/lib/common/npm.js.map +1 -1
  40. package/lib/common/pack.js +1 -1
  41. package/lib/common/pack.js.map +1 -1
  42. package/lib/common/package.d.ts +6 -6
  43. package/lib/common/package.js +10 -1
  44. package/lib/common/package.js.map +1 -1
  45. package/lib/common/scaffold.js +2 -2
  46. package/lib/common/scaffold.js.map +1 -1
  47. package/lib/external/index.js +1982 -92
  48. package/lib/helpers.js +1 -1
  49. package/lib/helpers.js.map +1 -1
  50. package/lib/injectors/pilet.js +2 -2
  51. package/lib/injectors/pilet.js.map +1 -1
  52. package/lib/plugin.js +4 -4
  53. package/lib/plugin.js.map +1 -1
  54. package/lib/types/internal.d.ts +9 -1
  55. package/lib/types/public.d.ts +1 -1
  56. package/package.json +4 -2
  57. package/src/apps/new-pilet.ts +9 -13
  58. package/src/apps/new-piral.ts +9 -5
  59. package/src/apps/publish-pilet.ts +2 -2
  60. package/src/apps/publish-piral.ts +2 -2
  61. package/src/apps/upgrade-pilet.ts +4 -12
  62. package/src/apps/upgrade-piral.ts +2 -2
  63. package/src/bundler.test.ts +1 -1
  64. package/src/bundler.ts +2 -2
  65. package/src/common/clients/index.ts +33 -0
  66. package/src/common/clients/lerna.ts +35 -1
  67. package/src/common/clients/npm.ts +20 -15
  68. package/src/common/clients/pnpm.ts +15 -12
  69. package/src/common/clients/rush.ts +85 -0
  70. package/src/common/clients/yarn.ts +17 -14
  71. package/src/common/emulator.ts +2 -2
  72. package/src/common/inspect.ts +2 -1
  73. package/src/common/npm.test.ts +51 -62
  74. package/src/common/npm.ts +82 -128
  75. package/src/common/pack.test.ts +1 -1
  76. package/src/common/pack.ts +2 -2
  77. package/src/common/package.ts +16 -7
  78. package/src/common/scaffold.ts +2 -2
  79. package/src/external/index.ts +2 -1
  80. package/src/helpers.ts +1 -1
  81. package/src/injectors/pilet.ts +3 -3
  82. package/src/plugin.ts +4 -4
  83. package/src/types/internal.ts +6 -1
  84. package/src/types/public.ts +1 -1
package/src/common/npm.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { resolve, relative, dirname } from 'path';
2
- import { createReadStream, existsSync, access, constants } from 'fs';
2
+ import { createReadStream, existsSync } from 'fs';
3
3
  import { log, fail } from './log';
4
+ import { clients, detectClients, isWrapperClient } from './clients';
4
5
  import { config } from './config';
5
6
  import { legacyCoreExternals, frameworkLibs } from './constants';
6
7
  import { inspectPackage } from './inspect';
@@ -23,48 +24,28 @@ function resolveAbsPath(basePath: string, fullName: string) {
23
24
  return resolve(basePath, relPath);
24
25
  }
25
26
 
26
- export function detectPnpm(root: string) {
27
- return new Promise((res) => {
28
- access(resolve(root, 'pnpm-lock.yaml'), constants.F_OK, (noPnpmLock) => {
29
- res(!noPnpmLock);
30
- });
31
- });
32
- }
33
-
34
- export function detectNpm(root: string) {
35
- return new Promise((res) => {
36
- access(resolve(root, 'package-lock.json'), constants.F_OK, (noPackageLock) => {
37
- res(!noPackageLock);
38
- });
39
- });
40
- }
41
-
42
- export async function detectYarn(root: string) {
43
- return !!(await findFile(root, 'yarn.lock'));
44
- }
45
-
46
- export async function getLernaConfigPath(root: string) {
47
- log('generalDebug_0003', 'Trying to get the configuration file for Lerna ...');
48
- const file = await findFile(root, 'lerna.json');
27
+ async function detectMonorepoRoot(root: string): Promise<string> {
28
+ let previous = root;
49
29
 
50
- if (file) {
51
- log('generalDebug_0003', `Found Lerna config in "${file}".`);
52
- return file;
53
- }
30
+ do {
31
+ const isMonorepo =
32
+ (await checkExists(resolve(root, 'lerna.json'))) ||
33
+ (await checkExists(resolve(root, 'rush.json'))) ||
34
+ (await checkExists(resolve(root, 'pnpm-workspace.yaml')));
54
35
 
55
- return undefined;
56
- }
36
+ if (isMonorepo) {
37
+ return root;
38
+ }
57
39
 
58
- export async function getLernaNpmClient(root: string): Promise<NpmClientType> {
59
- const file = await getLernaConfigPath(root);
40
+ const packageJson = await readJson(root, 'package.json');
60
41
 
61
- if (file) {
62
- try {
63
- return require(file).npmClient;
64
- } catch (err) {
65
- log('generalError_0002', `Could not read lerna.json: ${err}.`);
42
+ if (Array.isArray(packageJson?.workspaces)) {
43
+ return root;
66
44
  }
67
- }
45
+
46
+ previous = root;
47
+ root = dirname(root);
48
+ } while (root !== previous);
68
49
 
69
50
  return undefined;
70
51
  }
@@ -76,36 +57,45 @@ export async function getLernaNpmClient(root: string): Promise<NpmClientType> {
76
57
  */
77
58
  export async function determineNpmClient(root: string, selected?: NpmClientType): Promise<NpmClientType> {
78
59
  if (!selected || !clientTypeKeys.includes(selected)) {
79
- log('generalDebug_0003', 'No npm client selected. Checking for lock files ...');
80
- const [hasNpm, hasYarn, hasPnpm] = await Promise.all([detectNpm(root), detectYarn(root), detectPnpm(root)]);
81
- const found = +hasNpm + +hasYarn + +hasPnpm;
82
- log('generalDebug_0003', `Results of the lock file check: npm = ${hasNpm}, Yarn = ${hasYarn}, Pnpm = ${hasPnpm}`);
60
+ log('generalDebug_0003', 'No npm client selected. Checking for lock or config files ...');
61
+
62
+ const searchedClients = await detectClients(root);
63
+ const foundClients = searchedClients.filter((m) => m.result);
64
+
65
+ log(
66
+ 'generalDebug_0003',
67
+ `Results of the lock file check: ${searchedClients.map((m) => `${m.client}=${m.result}`).join(', ')}`,
68
+ );
69
+
83
70
  const defaultClient = config.npmClient;
84
71
 
85
- if (found !== 1) {
86
- const lernaClient = await getLernaNpmClient(root);
72
+ if (foundClients.length > 1) {
73
+ const wrapperClient = foundClients.find((m) => isWrapperClient(m.client));
74
+
75
+ if (wrapperClient) {
76
+ const { client } = wrapperClient;
77
+ log('generalDebug_0003', `Found valid wrapper client via lock or config file: "${client}".`);
78
+ }
79
+ }
80
+
81
+ if (foundClients.length > 0) {
82
+ const { client } = foundClients[0];
87
83
 
88
- if (clientTypeKeys.includes(lernaClient)) {
89
- log('generalDebug_0003', `Found valid npm client via Lerna: ${lernaClient}.`);
90
- return lernaClient;
84
+ if (foundClients.length > 1) {
85
+ const clientStr = `"${foundClients.map((m) => m.client).join('", "')}"`;
86
+ log('generalWarning_0001', `Found multiple clients via their lock or config files: ${clientStr}.`);
91
87
  }
92
- } else if (hasNpm) {
93
- log('generalDebug_0003', `Found valid npm client via lockfile.`);
94
- return 'npm';
95
- } else if (hasYarn) {
96
- log('generalDebug_0003', `Found valid Yarn client via lockfile.`);
97
- return 'yarn';
98
- } else if (hasPnpm) {
99
- log('generalDebug_0003', `Found valid pnpm client via lockfile.`);
100
- return 'pnpm';
88
+
89
+ log('generalDebug_0003', `Found valid direct client via lock or config file: "${client}".`);
90
+ return client;
101
91
  }
102
92
 
103
93
  if (clientTypeKeys.includes(defaultClient)) {
104
- log('generalDebug_0003', `Found valid Pnpm client the default client: "${defaultClient}".`);
94
+ log('generalDebug_0003', `Using the default client: "${defaultClient}".`);
105
95
  return defaultClient;
106
96
  }
107
97
 
108
- log('generalDebug_0003', 'Using the default npm client.');
98
+ log('generalDebug_0003', 'Using the default "npm" client.');
109
99
  return 'npm';
110
100
  }
111
101
 
@@ -113,103 +103,67 @@ export async function determineNpmClient(root: string, selected?: NpmClientType)
113
103
  }
114
104
 
115
105
  export async function isMonorepoPackageRef(refName: string, root: string): Promise<boolean> {
116
- const c = require(`./clients/npm`);
117
106
  const newRoot = await detectMonorepoRoot(root);
118
107
 
119
108
  if (newRoot) {
120
- const details = await c.listPackage(refName, newRoot);
109
+ const { listPackage } = clients.npm;
110
+ const details = await listPackage(refName, newRoot);
121
111
  return details?.dependencies?.[refName]?.extraneous ?? false;
122
112
  }
123
113
 
124
114
  return false;
125
115
  }
126
116
 
127
- export async function detectMonorepoRoot(root: string): Promise<string> {
128
- const file = await getLernaConfigPath(root);
129
-
130
- if (file !== undefined) {
131
- return dirname(file);
132
- }
133
-
134
- let previous = root;
135
-
136
- do {
137
- const packageJson = await readJson(root, 'package.json');
138
-
139
- if (Array.isArray(packageJson?.workspaces)) {
140
- return root;
141
- }
142
-
143
- previous = root;
144
- root = dirname(root);
145
- } while (root !== previous);
146
-
147
- return undefined;
148
- }
149
-
150
- export type MonorepoKind = 'none' | 'lerna' | 'yarn';
151
-
152
- export async function detectMonorepo(root: string): Promise<MonorepoKind> {
153
- const newRoot = await detectMonorepoRoot(root);
154
-
155
- if (newRoot) {
156
- const file = await getLernaConfigPath(newRoot);
157
-
158
- if (file !== undefined) {
159
- return 'lerna';
160
- }
161
-
162
- const packageJson = await readJson(newRoot, 'package.json');
163
-
164
- if (Array.isArray(packageJson?.workspaces)) {
165
- return 'yarn';
166
- }
167
- }
168
-
169
- return 'none';
170
- }
171
-
172
- export function bootstrapMonorepo(target = '.') {
173
- const c = require(`./clients/lerna`);
174
- return c.bootstrap(target);
175
- }
176
-
177
- export function installDependencies(client: NpmClientType, target = '.'): Promise<string> {
178
- const c = require(`./clients/${client}`);
179
- return c.installDependencies(target);
117
+ export function installNpmDependencies(client: NpmClientType, target = '.'): Promise<string> {
118
+ const { installDependencies } = clients[client];
119
+ return installDependencies(target);
180
120
  }
181
121
 
182
- export function installPackage(
122
+ export async function installNpmPackage(
183
123
  client: NpmClientType,
184
124
  packageRef: string,
185
125
  target = '.',
186
126
  ...flags: Array<string>
187
127
  ): Promise<string> {
188
- const c = require(`./clients/${client}`);
189
- return c.installPackage(packageRef, target, ...flags);
128
+ try {
129
+ const { installPackage } = clients[client];
130
+ return await installPackage(packageRef, target, ...flags);
131
+ } catch (ex) {
132
+ log(
133
+ 'generalError_0002',
134
+ `Could not install the package "${packageRef}" using ${client}. Make sure ${client} is correctly installed and accessible: ${ex}`,
135
+ );
136
+ throw ex;
137
+ }
138
+ }
139
+
140
+ export function initNpmProject(client: NpmClientType, projectName: string, target: string) {
141
+ const { initProject } = clients[client];
142
+ return initProject(projectName, target);
190
143
  }
191
144
 
192
- export function publishPackage(target = '.', file = '*.tgz', flags: Array<string> = []): Promise<string> {
193
- const c = require(`./clients/npm`);
194
- return c.publishPackage(target, file, ...flags);
145
+ export function publishNpmPackage(target = '.', file = '*.tgz', flags: Array<string> = []): Promise<string> {
146
+ const { publishPackage } = clients.npm;
147
+ return publishPackage(target, file, ...flags);
195
148
  }
196
149
 
197
- export function createPackage(target = '.'): Promise<string> {
198
- const c = require(`./clients/npm`);
199
- return c.createPackage(target);
150
+ export function createNpmPackage(target = '.'): Promise<string> {
151
+ const { createPackage } = clients.npm;
152
+ return createPackage(target);
200
153
  }
201
154
 
202
- export function findTarball(packageRef: string): Promise<string> {
203
- const c = require(`./clients/npm`);
204
- return c.findTarball(packageRef);
155
+ export function findNpmTarball(packageRef: string): Promise<string> {
156
+ const { findTarball } = clients.npm;
157
+ return findTarball(packageRef);
205
158
  }
206
159
 
207
160
  export function findSpecificVersion(packageName: string, version: string): Promise<string> {
208
- const c = require(`./clients/npm`);
209
- return c.findSpecificVersion(packageName, version);
161
+ const { findSpecificVersion } = clients.npm;
162
+ return findSpecificVersion(packageName, version);
210
163
  }
211
164
 
212
165
  export function findLatestVersion(packageName: string) {
166
+ const { findSpecificVersion } = clients.npm;
213
167
  return findSpecificVersion(packageName, 'latest');
214
168
  }
215
169
 
@@ -455,7 +409,7 @@ export function makePiletExternals(
455
409
  externals: Array<string>,
456
410
  fromEmulator: boolean,
457
411
  piralInfo: any,
458
- ) {
412
+ ): Array<string> {
459
413
  if (fromEmulator) {
460
414
  const { sharedDependencies = makeExternals(dependencies, externals, true) } = piralInfo;
461
415
  return sharedDependencies;
@@ -13,7 +13,7 @@ jest.mock('./io', () => ({
13
13
  }));
14
14
 
15
15
  jest.mock('./npm', () => ({
16
- createPackage: (target?: string) => {
16
+ createNpmPackage: (target?: string) => {
17
17
  return Promise.resolve(target);
18
18
  },
19
19
  }));
@@ -1,7 +1,7 @@
1
1
  import { resolve, join } from 'path';
2
2
  import { log, progress, fail } from './log';
3
3
  import { readJson, move } from './io';
4
- import { createPackage } from './npm';
4
+ import { createNpmPackage } from './npm';
5
5
  import { ForceOverwrite } from './enums';
6
6
 
7
7
  async function getFile(root: string, name: string, dest: string) {
@@ -38,7 +38,7 @@ export async function createPiletPackage(baseDir: string, source: string, target
38
38
 
39
39
  progress(`Packing pilet in ${dest} ...`);
40
40
  log('generalDebug_0003', 'Creating package ...');
41
- await createPackage(root);
41
+ await createNpmPackage(root);
42
42
  log('generalDebug_0003', 'Successfully created package.');
43
43
  const name = `${pckg.name}-${pckg.version}.tgz`.replace(/@/g, '').replace(/\//g, '-');
44
44
  log('generalDebug_0003', `Assumed package name "${name}".`);
@@ -12,7 +12,7 @@ import { isGitPackage, isLocalPackage, makeGitUrl, makeFilePath, makePiletExtern
12
12
  import { filesTar, filesOnceTar, declarationEntryExtensions, bundlerNames } from './constants';
13
13
  import { getHash, checkIsDirectory, matchFiles } from './io';
14
14
  import { readJson, copy, updateExistingJson, findFile, checkExists } from './io';
15
- import { Framework, FileInfo, PiletsInfo, TemplateFileLocation, SharedDependency } from '../types';
15
+ import { Framework, FileInfo, PiletsInfo, TemplateFileLocation, SharedDependency, PackageData } from '../types';
16
16
 
17
17
  function appendBundler(devDependencies: Record<string, string>, bundler: string, version: string) {
18
18
  if (bundler && bundler !== 'none') {
@@ -159,7 +159,7 @@ function findPackage(pck: string | Array<string>, baseDir: string) {
159
159
  return undefined;
160
160
  }
161
161
 
162
- export function readPiralPackage(root: string, name: string) {
162
+ export function readPiralPackage(root: string, name: string): Promise<PackageData> {
163
163
  log('generalDebug_0003', `Reading the piral package in "${root}" ...`);
164
164
  const path = getPiralPath(root, name);
165
165
  return readJson(path, 'package.json');
@@ -319,10 +319,19 @@ function isTemplateFileLocation(item: string | TemplateFileLocation): item is Te
319
319
  return typeof item === 'object';
320
320
  }
321
321
 
322
+ function tryFindPackageVersion(packageName: string): string {
323
+ try {
324
+ const { version } = require(`${packageName}/package.json`);
325
+ return version;
326
+ } catch {
327
+ return undefined;
328
+ }
329
+ }
330
+
322
331
  export async function copyPiralFiles(
323
332
  root: string,
324
333
  name: string,
325
- piralInfo: any,
334
+ piralInfo: PackageData,
326
335
  forceOverwrite: ForceOverwrite,
327
336
  variables: Record<string, string>,
328
337
  originalFiles?: Array<FileInfo>,
@@ -342,7 +351,7 @@ export async function copyPiralFiles(
342
351
  await copyFiles(files, forceOverwrite, originalFiles, variables);
343
352
  }
344
353
 
345
- export function getPiletsInfo(piralInfo: any): PiletsInfo {
354
+ export function getPiletsInfo(piralInfo: Partial<PackageData>): PiletsInfo {
346
355
  const {
347
356
  files = [],
348
357
  externals = [],
@@ -491,7 +500,7 @@ export async function patchPiletPackage(
491
500
  root: string,
492
501
  name: string,
493
502
  version: string,
494
- piralInfo: any,
503
+ piralInfo: PackageData,
495
504
  fromEmulator: boolean,
496
505
  newInfo?: { language: SourceLanguage; bundler: string },
497
506
  ) {
@@ -539,7 +548,7 @@ export async function patchPiletPackage(
539
548
  return deps;
540
549
  }, {}),
541
550
  ...allExternals.filter(isValidDependency).reduce((deps, name) => {
542
- const version = piralDependencies[name];
551
+ const version = piralDependencies[name] || tryFindPackageVersion(name);
543
552
 
544
553
  if (version || newInfo) {
545
554
  // set only if we have an explicit version or we are in the scaffolding case
@@ -576,7 +585,7 @@ export async function patchPiletPackage(
576
585
  /**
577
586
  * Returns true if its an emulator package, otherwise it has to be a "raw" app shell.
578
587
  */
579
- export function checkAppShellPackage(appPackage: any) {
588
+ export function checkAppShellPackage(appPackage: PackageData) {
580
589
  const { piralCLI = { generated: false, version: cliVersion } } = appPackage;
581
590
 
582
591
  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 { log, fail } from './log';
@@ -36,7 +36,7 @@ async function getTemplateFiles(
36
36
  if (templatePackageName.startsWith('.')) {
37
37
  templatePackageName = resolve(process.cwd(), templatePackageName);
38
38
  } else {
39
- await installPackage(templatePackageName, __dirname, '--registry', registry);
39
+ await installNpmPackage('npm', templatePackageName, __dirname, '--registry', registry);
40
40
  }
41
41
 
42
42
  const templateRunner = getTemplatePackage(templatePackageName);
@@ -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
@@ -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,7 +6,7 @@ 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;
@@ -35,8 +35,8 @@ function fillPiletMeta(pilet: Pilet, basePath: string, metaFile: string) {
35
35
  const { root, bundler } = pilet;
36
36
  const metaPath = join(root, metaFile);
37
37
  const packagePath = join(root, 'package.json');
38
- const def = JSON.parse(readFileSync(packagePath, 'utf8'));
39
- 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;
40
40
  const file = bundler.bundle.name.replace(/^[\/\\]/, '');
41
41
  const target = join(bundler.bundle.dir, file);
42
42
  const url = new URL(file, basePath);
package/src/plugin.ts CHANGED
@@ -6,11 +6,11 @@ import { inject } from './inject';
6
6
  function getContainerDir() {
7
7
  const currentDir = __dirname.split(sep).join(posix.sep);
8
8
 
9
- if (currentDir.includes(`/.pnpm/${cliName}@${cliVersion}/node_modules/${cliName}/`)) {
10
- return resolve(__dirname, '..', '..', '..', '..', '..');
9
+ if (!currentDir.includes(`/.pnpm/${cliName}@${cliVersion}/node_modules/${cliName}/`)) {
10
+ return resolve(__dirname, '..', '..');
11
11
  }
12
12
 
13
- return resolve(__dirname, '..', '..');
13
+ return undefined;
14
14
  }
15
15
 
16
16
  async function getLocalPackageDir() {
@@ -25,7 +25,7 @@ async function getLocalPackageDir() {
25
25
  // Right now we always take the first one, but in the future this may be different
26
26
  // once we come up with more / better criteria to identify if its a good/valid
27
27
  // plugin root directory
28
- for (const dir of proposedDirs) {
28
+ for (const dir of proposedDirs.filter(Boolean)) {
29
29
  log('generalDebug_0003', `Checking for potential plugin directory "${dir}" ...`);
30
30
 
31
31
  if (await isDirectory(dir)) {
@@ -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 {
@@ -226,7 +226,7 @@ export type PiletBuildType = 'default' | 'standalone' | 'manifest';
226
226
 
227
227
  export type PackageType = 'registry' | 'file' | 'git';
228
228
 
229
- export type NpmClientType = 'npm' | 'yarn' | 'pnpm';
229
+ export type NpmClientType = 'npm' | 'yarn' | 'pnpm' | 'lerna' | 'rush';
230
230
 
231
231
  export type Framework = 'piral' | 'piral-core' | 'piral-base';
232
232