piral-cli 1.3.3-beta.6190 → 1.3.3-beta.6201

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 (92) hide show
  1. package/lib/bundler.js +25 -1
  2. package/lib/bundler.js.map +1 -1
  3. package/lib/cli.js +5 -2
  4. package/lib/cli.js.map +1 -1
  5. package/lib/commands.js +24 -1
  6. package/lib/commands.js.map +1 -1
  7. package/lib/common/io.js +5 -2
  8. package/lib/common/io.js.map +1 -1
  9. package/lib/common/log.js +24 -1
  10. package/lib/common/log.js.map +1 -1
  11. package/lib/common/npm.js +13 -13
  12. package/lib/common/npm.js.map +1 -1
  13. package/lib/external/index.js +426 -230
  14. package/lib/inject.js +24 -1
  15. package/lib/inject.js.map +1 -1
  16. package/lib/{common/clients → npm-clients}/bun.js +5 -5
  17. package/lib/npm-clients/bun.js.map +1 -0
  18. package/lib/{common/clients → npm-clients}/index.js +31 -8
  19. package/lib/npm-clients/index.js.map +1 -0
  20. package/lib/{common/clients → npm-clients}/lerna.js +4 -4
  21. package/lib/npm-clients/lerna.js.map +1 -0
  22. package/lib/{common/clients → npm-clients}/npm.js +4 -4
  23. package/lib/npm-clients/npm.js.map +1 -0
  24. package/lib/{common/clients → npm-clients}/pnp.js +4 -4
  25. package/lib/npm-clients/pnp.js.map +1 -0
  26. package/lib/{common/clients → npm-clients}/pnpm.js +4 -4
  27. package/lib/npm-clients/pnpm.js.map +1 -0
  28. package/lib/{common/clients → npm-clients}/rush.js +5 -5
  29. package/lib/npm-clients/rush.js.map +1 -0
  30. package/lib/{common/clients → npm-clients}/yarn.js +4 -4
  31. package/lib/npm-clients/yarn.js.map +1 -0
  32. package/package.json +2 -2
  33. package/src/apps/build-pilet.test.ts +1 -0
  34. package/src/apps/build-piral.test.ts +19 -12
  35. package/src/apps/new-pilet.test.ts +120 -76
  36. package/src/apps/new-piral.test.ts +100 -77
  37. package/src/apps/pack-pilet.test.ts +2 -3
  38. package/src/apps/upgrade-pilet.test.ts +1 -0
  39. package/src/bundler.test.ts +8 -7
  40. package/src/bundler.ts +2 -1
  41. package/src/cli.ts +1 -1
  42. package/src/common/archive.test.ts +10 -7
  43. package/src/common/browser.test.ts +2 -1
  44. package/src/common/compatibility.test.ts +1 -0
  45. package/src/common/envs.test.ts +2 -1
  46. package/src/common/hash.test.ts +1 -0
  47. package/src/common/http.test.ts +73 -70
  48. package/src/common/importmap.test.ts +3 -2
  49. package/src/common/info.test.ts +1 -0
  50. package/src/common/interactive.test.ts +2 -1
  51. package/src/common/io.ts +1 -1
  52. package/src/common/merge.test.ts +1 -0
  53. package/src/common/npm.test.ts +35 -37
  54. package/src/common/npm.ts +1 -1
  55. package/src/common/pack.test.ts +11 -10
  56. package/src/common/package.test.ts +131 -92
  57. package/src/common/parallel.test.ts +1 -0
  58. package/src/common/patches.test.ts +1 -0
  59. package/src/common/port.test.ts +2 -1
  60. package/src/common/rules.test.ts +4 -3
  61. package/src/common/url.test.ts +1 -0
  62. package/src/common/utils.test.ts +1 -0
  63. package/src/common/version.test.ts +1 -0
  64. package/src/external/index.test.ts +1 -0
  65. package/src/helpers.test.ts +1 -0
  66. package/src/injectors/pilet-injector.test.ts +6 -5
  67. package/src/injectors/piral-injector.test.ts +7 -6
  68. package/src/{common/clients → npm-clients}/bun.ts +5 -5
  69. package/src/{common/clients → npm-clients}/index.ts +1 -1
  70. package/src/{common/clients → npm-clients}/lerna.ts +4 -4
  71. package/src/{common/clients → npm-clients}/npm.ts +4 -4
  72. package/src/{common/clients → npm-clients}/pnp.ts +4 -4
  73. package/src/{common/clients → npm-clients}/pnpm.ts +4 -4
  74. package/src/{common/clients → npm-clients}/rush.ts +5 -5
  75. package/src/{common/clients → npm-clients}/yarn.ts +4 -4
  76. package/src/rules/pilet-has-externals-as-peers.test.ts +4 -3
  77. package/lib/common/clients/bun.js.map +0 -1
  78. package/lib/common/clients/index.js.map +0 -1
  79. package/lib/common/clients/lerna.js.map +0 -1
  80. package/lib/common/clients/npm.js.map +0 -1
  81. package/lib/common/clients/pnp.js.map +0 -1
  82. package/lib/common/clients/pnpm.js.map +0 -1
  83. package/lib/common/clients/rush.js.map +0 -1
  84. package/lib/common/clients/yarn.js.map +0 -1
  85. /package/lib/{common/clients → npm-clients}/bun.d.ts +0 -0
  86. /package/lib/{common/clients → npm-clients}/index.d.ts +0 -0
  87. /package/lib/{common/clients → npm-clients}/lerna.d.ts +0 -0
  88. /package/lib/{common/clients → npm-clients}/npm.d.ts +0 -0
  89. /package/lib/{common/clients → npm-clients}/pnp.d.ts +0 -0
  90. /package/lib/{common/clients → npm-clients}/pnpm.d.ts +0 -0
  91. /package/lib/{common/clients → npm-clients}/rush.d.ts +0 -0
  92. /package/lib/{common/clients → npm-clients}/yarn.d.ts +0 -0
@@ -1,5 +1,6 @@
1
+ import { describe, it, expect, vitest } from 'vitest';
1
2
  import { resolve } from 'path';
2
- import { clients } from './clients';
3
+ import { clients } from '../npm-clients';
3
4
  import {
4
5
  dissectPackageName,
5
6
  installNpmPackage,
@@ -24,10 +25,10 @@ import {
24
25
  findPackageRoot,
25
26
  } from './npm';
26
27
 
27
- jest.mock('child_process');
28
+ vitest.mock('child_process');
28
29
 
29
- jest.mock('../external', () => ({
30
- ...jest.requireActual('../external'),
30
+ vitest.mock('../external', async () => ({
31
+ ...((await vitest.importActual('../external')) as any),
31
32
  rc() {},
32
33
  ora() {
33
34
  return {
@@ -58,7 +59,7 @@ let wrongCase = false;
58
59
  const jsonValueString = JSON.stringify([{ name: 'npm' }]);
59
60
  const jsonValueStringWrong = JSON.stringify([]);
60
61
 
61
- jest.mock('./scripts', () => ({
62
+ vitest.mock('./scripts', () => ({
62
63
  runCommand: (exe: string, args: Array<string>, cwd: string, output?: NodeJS.WritableStream) => {
63
64
  return new Promise<void>((resolve) => {
64
65
  output?.write(wrongCase ? jsonValueStringWrong : jsonValueString, () => {});
@@ -67,29 +68,34 @@ jest.mock('./scripts', () => ({
67
68
  },
68
69
  }));
69
70
 
70
- jest.mock('fs', () => ({
71
- ...jest.requireActual('fs'),
72
- exists: (file: string, cb: (status: boolean) => void) =>
73
- cb(
74
- shouldFind &&
75
- !file.endsWith('package.json') &&
76
- !(specialCase && (file.endsWith('lerna.json') || file.endsWith('yarn.lock'))),
77
- ),
78
- existsSync: (file: string) => {
79
- return true;
80
- },
81
- readFile: (file: string, type: string, callback: (err: NodeJS.ErrnoException | undefined, data: string) => void) => {
82
- const fs = jest.requireActual('fs');
83
-
84
- if (fs.existsSync(file)) {
85
- return fs.readFile(file, type, callback);
86
- }
87
-
88
- return callback(undefined, '');
89
- },
90
- realpathSync: () => ({}),
91
- readFileSync: () => '',
92
- }));
71
+ vitest.mock('fs', async () => {
72
+ const fs = (await vitest.importActual('fs')) as any;
73
+ return {
74
+ ...fs,
75
+ exists: (file: string, cb: (status: boolean) => void) =>
76
+ cb(
77
+ shouldFind &&
78
+ !file.endsWith('package.json') &&
79
+ !(specialCase && (file.endsWith('lerna.json') || file.endsWith('yarn.lock'))),
80
+ ),
81
+ existsSync: (file: string) => {
82
+ return true;
83
+ },
84
+ readFile: (
85
+ file: string,
86
+ type: string,
87
+ callback: (err: NodeJS.ErrnoException | undefined, data: string) => void,
88
+ ) => {
89
+ if (fs.existsSync(file)) {
90
+ return fs.readFile(file, type, callback);
91
+ }
92
+
93
+ return callback(undefined, '');
94
+ },
95
+ realpathSync: () => ({}),
96
+ readFileSync: () => '',
97
+ };
98
+ });
93
99
 
94
100
  describe('npm Module', () => {
95
101
  it('findPackageRoot correctly resolves the package root of parcel-bundler', () => {
@@ -488,15 +494,7 @@ describe('npm Module', () => {
488
494
 
489
495
  it('makeExternals with externals concats coreExternals', async () => {
490
496
  const externals = await makeExternals(process.cwd(), { piral: '*' }, ['foo', 'bar']);
491
- expect(externals).toEqual([
492
- 'foo',
493
- 'bar',
494
- 'react',
495
- 'react-dom',
496
- 'react-router',
497
- 'react-router-dom',
498
- 'tslib',
499
- ]);
497
+ expect(externals).toEqual(['foo', 'bar', 'react', 'react-dom', 'react-router', 'react-router-dom', 'tslib']);
500
498
  });
501
499
 
502
500
  it('makeExternals with external duplicate only reflects coreExternals', async () => {
package/src/common/npm.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { resolve, relative, dirname } from 'path';
2
2
  import { createReadStream, existsSync } from 'fs';
3
3
  import { log, fail } from './log';
4
- import { clients, detectClients, isWrapperClient } from './clients';
5
4
  import { config } from './config';
6
5
  import { legacyCoreExternals, frameworkLibs, defaultRegistry, packageJson } from './constants';
7
6
  import { inspectPackage } from './inspect';
8
7
  import { readJson, checkExists } from './io';
8
+ import { clients, detectClients, isWrapperClient } from '../npm-clients';
9
9
  import { clientTypeKeys } from '../helpers';
10
10
  import { getModulePath } from '../external';
11
11
  import { PackageType, NpmClientType } from '../types';
@@ -1,20 +1,21 @@
1
+ import { describe, it, expect, vitest } from 'vitest';
1
2
  import { createPiletPackage } from './pack';
2
3
  import { resolve } from 'path';
3
4
 
4
5
  let json: any = {};
5
6
 
6
- jest.mock('./io', () => ({
7
- readJson: jest.fn(() => json),
8
- removeDirectory: jest.fn(() => Promise.resolve()),
9
- checkIsDirectory: jest.fn(() => false),
10
- makeTempDir: jest.fn(() => Promise.resolve('')),
11
- copy: jest.fn(() => Promise.resolve()),
12
- checkExists: jest.fn(() => Promise.resolve(true)),
13
- createDirectory: jest.fn(() => Promise.resolve()),
7
+ vitest.mock('./io', () => ({
8
+ readJson: vitest.fn(() => json),
9
+ removeDirectory: vitest.fn(() => Promise.resolve()),
10
+ checkIsDirectory: vitest.fn(() => false),
11
+ makeTempDir: vitest.fn(() => Promise.resolve('')),
12
+ copy: vitest.fn(() => Promise.resolve()),
13
+ checkExists: vitest.fn(() => Promise.resolve(true)),
14
+ createDirectory: vitest.fn(() => Promise.resolve()),
14
15
  }));
15
16
 
16
- jest.mock('./archive', () => ({
17
- createTgz: jest.fn(() => Promise.resolve()),
17
+ vitest.mock('./archive', () => ({
18
+ createTgz: vitest.fn(() => Promise.resolve()),
18
19
  }));
19
20
 
20
21
  describe('Pack Module', () => {
@@ -1,115 +1,154 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { findPackageVersion, getPiralPackage, getPiletsInfo, retrievePiletData } from './package';
2
3
  import { cliVersion } from './info';
3
4
 
4
- describe('CLI package module', () => {
5
- jest.setTimeout(15000);
6
-
7
- it('findPackageVersion finds the current package version', async () => {
8
- const version = await findPackageVersion(process.cwd(), 'sample-piral');
9
- expect(version).toBe(cliVersion);
10
- });
5
+ const testOptions = {
6
+ timeout: 10000,
7
+ };
11
8
 
12
- it('findPackageVersion falls back to latest', async () => {
13
- const version = await findPackageVersion(process.cwd(), 'foo-bar-not-exists');
14
- expect(version).toBe('latest');
15
- });
9
+ describe('CLI package module', () => {
10
+ it(
11
+ 'findPackageVersion finds the current package version',
12
+ async () => {
13
+ const version = await findPackageVersion(process.cwd(), 'sample-piral');
14
+ expect(version).toBe(cliVersion);
15
+ },
16
+ testOptions,
17
+ );
16
18
 
17
- it('getPiletsInfo returns pilets information about provided piralInfo', () => {
18
- const emptyPiletsInfo = {
19
- files: [],
20
- template: 'default',
21
- scripts: {},
22
- validators: {},
23
- devDependencies: {},
24
- preScaffold: '',
25
- postScaffold: '',
26
- packageOverrides: {},
27
- preUpgrade: '',
28
- postUpgrade: '',
29
- };
30
- let result = getPiletsInfo({});
31
- expect(result).toStrictEqual(emptyPiletsInfo);
19
+ it(
20
+ 'findPackageVersion falls back to latest',
21
+ async () => {
22
+ const version = await findPackageVersion(process.cwd(), 'foo-bar-not-exists');
23
+ expect(version).toBe('latest');
24
+ },
25
+ testOptions,
26
+ );
32
27
 
33
- const piralInfo = {
34
- pilets: {
35
- files: ['foo.tgz', 'foo2.tgz'],
28
+ it(
29
+ 'getPiletsInfo returns pilets information about provided piralInfo',
30
+ () => {
31
+ const emptyPiletsInfo = {
32
+ files: [],
36
33
  template: 'default',
37
34
  scripts: {},
38
35
  validators: {},
39
36
  devDependencies: {},
40
37
  preScaffold: '',
41
- packageOverrides: {},
42
38
  postScaffold: '',
39
+ packageOverrides: {},
43
40
  preUpgrade: '',
44
41
  postUpgrade: '',
45
- },
46
- };
47
- result = getPiletsInfo(piralInfo);
48
- expect(result).toStrictEqual(piralInfo.pilets);
49
- });
42
+ };
43
+ let result = getPiletsInfo({});
44
+ expect(result).toStrictEqual(emptyPiletsInfo);
45
+
46
+ const piralInfo = {
47
+ pilets: {
48
+ files: ['foo.tgz', 'foo2.tgz'],
49
+ template: 'default',
50
+ scripts: {},
51
+ validators: {},
52
+ devDependencies: {},
53
+ preScaffold: '',
54
+ packageOverrides: {},
55
+ postScaffold: '',
56
+ preUpgrade: '',
57
+ postUpgrade: '',
58
+ },
59
+ };
60
+ result = getPiletsInfo(piralInfo);
61
+ expect(result).toStrictEqual(piralInfo.pilets);
62
+ },
63
+ testOptions,
64
+ );
50
65
 
51
- it('getPiralPackage returns piral package with webpack in latest version',async () => {
52
- const result = await getPiralPackage(
53
- 'app',
54
- { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
55
- '10.0.0',
56
- 'webpack',
57
- );
58
- expect(result.devDependencies['piral-cli-webpack']).toEqual('latest');
59
- });
66
+ it(
67
+ 'getPiralPackage returns piral package with webpack in latest version',
68
+ async () => {
69
+ const result = await getPiralPackage(
70
+ 'app',
71
+ { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
72
+ '10.0.0',
73
+ 'webpack',
74
+ );
75
+ expect(result.devDependencies['piral-cli-webpack']).toEqual('latest');
76
+ },
77
+ testOptions,
78
+ );
60
79
 
61
- it('getPiralPackage returns piral package with webpack in beta version',async () => {
62
- const result = await getPiralPackage(
63
- 'app',
64
- { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
65
- '0.15.0-beta.1',
66
- 'webpack',
67
- );
68
- expect(result.devDependencies['piral-cli-webpack']).toEqual('next');
69
- });
80
+ it(
81
+ 'getPiralPackage returns piral package with webpack in beta version',
82
+ async () => {
83
+ const result = await getPiralPackage(
84
+ 'app',
85
+ { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
86
+ '0.15.0-beta.1',
87
+ 'webpack',
88
+ );
89
+ expect(result.devDependencies['piral-cli-webpack']).toEqual('next');
90
+ },
91
+ testOptions,
92
+ );
70
93
 
71
- it('getPiralPackage returns piral package with webpack in alpha version',async () => {
72
- const result = await getPiralPackage(
73
- 'app',
74
- { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
75
- '0.15.0-alpha.1',
76
- 'webpack',
77
- );
78
- expect(result.devDependencies['piral-cli-webpack']).toEqual('canary');
79
- });
94
+ it(
95
+ 'getPiralPackage returns piral package with webpack in alpha version',
96
+ async () => {
97
+ const result = await getPiralPackage(
98
+ 'app',
99
+ { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
100
+ '0.15.0-alpha.1',
101
+ 'webpack',
102
+ );
103
+ expect(result.devDependencies['piral-cli-webpack']).toEqual('canary');
104
+ },
105
+ testOptions,
106
+ );
80
107
 
81
- it('getPiralPackage returns piral package with webpack in existing version',async () => {
82
- const result = await getPiralPackage(
83
- 'app',
84
- { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
85
- '0.14.0',
86
- 'webpack',
87
- );
88
- expect(result.devDependencies['piral-cli-webpack']).toEqual('0.14.0');
89
- });
108
+ it(
109
+ 'getPiralPackage returns piral package with webpack in existing version',
110
+ async () => {
111
+ const result = await getPiralPackage(
112
+ 'app',
113
+ { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
114
+ '0.14.0',
115
+ 'webpack',
116
+ );
117
+ expect(result.devDependencies['piral-cli-webpack']).toEqual('0.14.0');
118
+ },
119
+ testOptions,
120
+ );
90
121
 
91
- it('getPiralPackage returns piral package without bundler',async () => {
92
- const result = await getPiralPackage(
93
- 'app',
94
- { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
95
- '1.0.0',
96
- );
97
- expect(result.devDependencies).not.toContain('piral-cli-webpack');
98
- });
122
+ it(
123
+ 'getPiralPackage returns piral package without bundler',
124
+ async () => {
125
+ const result = await getPiralPackage(
126
+ 'app',
127
+ { language: 'ts', packageName: 'piral-base', reactRouterVersion: 5, reactVersion: 17 },
128
+ '1.0.0',
129
+ );
130
+ expect(result.devDependencies['piral-cli-webpack']).toBeUndefined();
131
+ },
132
+ testOptions,
133
+ );
99
134
 
100
- it('retrievePiletData error cases', async () => {
101
- await retrievePiletData('foo', '').catch((err) =>
102
- expect(err).toStrictEqual(Error('[0012] No Piral instances have been provided.')),
103
- );
135
+ it(
136
+ 'retrievePiletData error cases',
137
+ async () => {
138
+ await retrievePiletData('foo', '').catch((err) =>
139
+ expect(err).toStrictEqual(Error('[0012] No Piral instances have been provided.')),
140
+ );
104
141
 
105
- await retrievePiletData('foo', 'bar').catch((err) =>
106
- expect(err).toStrictEqual(Error('[0010] The defined Piral instance ("bar") could not be found.')),
107
- );
142
+ await retrievePiletData('foo', 'bar').catch((err) =>
143
+ expect(err).toStrictEqual(Error('[0010] The defined Piral instance ("bar") could not be found.')),
144
+ );
108
145
 
109
- await retrievePiletData('/foo', 'sample-piral').catch((err) =>
110
- expect(err).toStrictEqual(
111
- Error('[0075] Cannot find the "package.json". You need a valid package.json for your pilet.'),
112
- ),
113
- );
114
- });
146
+ await retrievePiletData('/foo', 'sample-piral').catch((err) =>
147
+ expect(err).toStrictEqual(
148
+ Error('[0075] Cannot find the "package.json". You need a valid package.json for your pilet.'),
149
+ ),
150
+ );
151
+ },
152
+ testOptions,
153
+ );
115
154
  });
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { concurrentWorkers } from './parallel';
2
3
 
3
4
  describe('Concurrent Workers', () => {
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { getPatch, installPatch } from './patches';
2
3
 
3
4
  const patchName = 'foo';
@@ -1,9 +1,10 @@
1
+ import { describe, it, expect, vitest } from 'vitest';
1
2
  import { getFreePort } from './port';
2
3
 
3
4
  const defaultPort = 12345;
4
5
  const error = Error('RangeError: Port should be >= 0 and < 65536.');
5
6
 
6
- jest.mock('../external', () => ({
7
+ vitest.mock('../external', () => ({
7
8
  ora() {
8
9
  return {};
9
10
  },
@@ -1,8 +1,9 @@
1
+ import { describe, it, expect, vitest } from 'vitest';
1
2
  import { ruleSummary, runRules } from './rules';
2
3
  import { chalk } from '../external';
3
4
 
4
5
  const rule = {
5
- run: jest.fn(),
6
+ run: vitest.fn(),
6
7
  name: 'test',
7
8
  };
8
9
 
@@ -13,11 +14,11 @@ describe('Rules Module', () => {
13
14
  };
14
15
  expect(runException).toThrow(Error('[0080] Validation failed. Found 1 error(s).'));
15
16
 
16
- let consoleSpy = jest.spyOn(process.stderr, 'write');
17
+ let consoleSpy = vitest.spyOn(process.stderr, 'write');
17
18
  ruleSummary([], []);
18
19
  expect(consoleSpy).toHaveBeenLastCalledWith(`${chalk.green('✔')} Validation successful. No errors or warnings.\n`);
19
20
 
20
- jest.clearAllMocks();
21
+ vitest.clearAllMocks();
21
22
  ruleSummary([], ['Warning!']);
22
23
  expect(consoleSpy).toHaveBeenCalled();
23
24
  });
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { normalizePublicUrl } from './url';
2
3
 
3
4
  describe('Url Module', () => {
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { onlyUnique, onlyUniqueFiles } from './utils';
2
3
 
3
4
  describe('only unique', () => {
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { satisfies, validate } from './version';
2
3
 
3
4
  describe('semver check module', () => {
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import * as externals from '../external';
2
3
 
3
4
  describe('Externals module', () => {
@@ -1,3 +1,4 @@
1
+ import { describe, it, expect } from 'vitest';
1
2
  import { keyOfForceOverwrite, valueOfForceOverwrite } from './helpers';
2
3
  import { ForceOverwrite } from './common/enums';
3
4
 
@@ -1,6 +1,7 @@
1
+ import PiletInjector from './pilet-injector';
2
+ import { describe, it, expect } from 'vitest';
1
3
  import { EventEmitter } from 'events';
2
4
  import { KrasRequest } from 'kras';
3
- import PiletInjector from './pilet-injector';
4
5
 
5
6
  const optionsMock = {
6
7
  pilets: [],
@@ -96,14 +97,14 @@ describe('Piral-CLI pilet injector', () => {
96
97
 
97
98
  const core = new EventEmitter();
98
99
  const injector = new PiletInjector(optionsMock, configMock, core);
99
- const request: KrasRequest = {
100
+ const request = {
100
101
  content: 'someFakeContent',
101
102
  headers: {},
102
103
  method: 'PUT',
103
104
  query: {},
104
105
  target: optionsMock.api,
105
106
  url: 'localhost:1234',
106
- };
107
+ } as KrasRequest;
107
108
 
108
109
  // Act
109
110
  const res = await injector.handle(request);
@@ -125,14 +126,14 @@ describe('Piral-CLI pilet injector', () => {
125
126
  };
126
127
  const core = new EventEmitter();
127
128
  const injector = new PiletInjector(optionsMock, configMock, core);
128
- const request: KrasRequest = {
129
+ const request = {
129
130
  content: 'someFakeContent',
130
131
  headers: {},
131
132
  method: 'PUT',
132
133
  query: {},
133
134
  target: '',
134
135
  url: 'localhost:1234',
135
- };
136
+ } as KrasRequest;
136
137
 
137
138
  // Act
138
139
  const res = injector.handle(request);
@@ -1,4 +1,5 @@
1
1
  import PiralInjector from './piral-injector';
2
+ import { describe, it, expect } from 'vitest';
2
3
  import { KrasRequest, KrasResult } from 'kras';
3
4
  import { EventEmitter } from 'events';
4
5
 
@@ -39,7 +40,7 @@ describe('Piral-CLI piral injector', () => {
39
40
  active: true,
40
41
  headers: {},
41
42
  };
42
- const injector = new PiralInjector(config, undefined, new EventEmitter());
43
+ const injector = new PiralInjector(config, undefined as any, new EventEmitter());
43
44
  expect(injector.active).toBeTruthy();
44
45
  });
45
46
 
@@ -51,7 +52,7 @@ describe('Piral-CLI piral injector', () => {
51
52
  active: true,
52
53
  headers: {},
53
54
  };
54
- const injector = new PiralInjector(config, undefined, new EventEmitter());
55
+ const injector = new PiralInjector(config, undefined as any, new EventEmitter());
55
56
 
56
57
  // Act
57
58
  injector.active = false;
@@ -71,7 +72,7 @@ describe('Piral-CLI piral injector', () => {
71
72
  active: true,
72
73
  headers: {},
73
74
  };
74
- const injector = new PiralInjector(config, undefined, new EventEmitter());
75
+ const injector = new PiralInjector(config, undefined as any, new EventEmitter());
75
76
 
76
77
  // Act
77
78
  const res = injector.sendResponse('some/nice/invalid/path', 'sometarget.file', 'someDir', 'localhost:1234');
@@ -88,15 +89,15 @@ describe('Piral-CLI piral injector', () => {
88
89
  active: true,
89
90
  headers: {},
90
91
  };
91
- const injector = new PiralInjector(config, undefined, new EventEmitter());
92
- const request: KrasRequest = {
92
+ const injector = new PiralInjector(config, undefined as any, new EventEmitter());
93
+ const request = {
93
94
  content: 'someFakeContent',
94
95
  headers: {},
95
96
  method: 'PUT',
96
97
  query: {},
97
98
  target: '',
98
99
  url: 'localhost:1234',
99
- };
100
+ } as KrasRequest;
100
101
 
101
102
  // Act
102
103
  const res = await (injector.handle(request) as Promise<KrasResult>);
@@ -1,8 +1,8 @@
1
1
  import { resolve } from 'path';
2
- import { log } from '../log';
3
- import { findFile } from '../io';
4
- import { runCommand } from '../scripts';
5
- import { MemoryStream } from '../MemoryStream';
2
+ import { log } from '../common/log';
3
+ import { findFile } from '../common/io';
4
+ import { runCommand } from '../common/scripts';
5
+ import { MemoryStream } from '../common/MemoryStream';
6
6
 
7
7
  // Helpers:
8
8
 
@@ -68,7 +68,7 @@ export async function isProject(root: string, packageRef: string) {
68
68
  return false;
69
69
  }
70
70
 
71
- // Functions to exclusively use from yarn client:
71
+ // Functions to exclusively use from Bun client:
72
72
 
73
73
  export async function listProjects(target: string) {
74
74
  const ms = new MemoryStream();
@@ -1,5 +1,5 @@
1
1
  import { dirname, resolve } from 'path';
2
- import { findFile } from '../io';
2
+ import { findFile } from '../common/io';
3
3
 
4
4
  import * as lerna from './lerna';
5
5
  import * as npm from './npm';
@@ -1,8 +1,8 @@
1
1
  import { resolve } from 'path';
2
- import { log } from '../log';
3
- import { findFile, readJson, writeJson } from '../io';
4
- import { runCommand } from '../scripts';
5
- import { MemoryStream } from '../MemoryStream';
2
+ import { log } from '../common/log';
3
+ import { findFile, readJson, writeJson } from '../common/io';
4
+ import { runCommand } from '../common/scripts';
5
+ import { MemoryStream } from '../common/MemoryStream';
6
6
 
7
7
  // Helpers:
8
8
 
@@ -1,8 +1,8 @@
1
1
  import { resolve } from 'path';
2
- import { log } from '../log';
3
- import { findFile } from '../io';
4
- import { runCommand } from '../scripts';
5
- import { MemoryStream } from '../MemoryStream';
2
+ import { log } from '../common/log';
3
+ import { findFile } from '../common/io';
4
+ import { runCommand } from '../common/scripts';
5
+ import { MemoryStream } from '../common/MemoryStream';
6
6
 
7
7
  // Helpers:
8
8
 
@@ -1,8 +1,8 @@
1
1
  import { resolve } from 'path';
2
- import { log } from '../log';
3
- import { findFile } from '../io';
4
- import { runCommand } from '../scripts';
5
- import { MemoryStream } from '../MemoryStream';
2
+ import { log } from '../common/log';
3
+ import { findFile } from '../common/io';
4
+ import { runCommand } from '../common/scripts';
5
+ import { MemoryStream } from '../common/MemoryStream';
6
6
 
7
7
  // Helpers:
8
8