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.
- package/lib/bundler.js +25 -1
- package/lib/bundler.js.map +1 -1
- package/lib/cli.js +5 -2
- package/lib/cli.js.map +1 -1
- package/lib/commands.js +24 -1
- package/lib/commands.js.map +1 -1
- package/lib/common/io.js +5 -2
- package/lib/common/io.js.map +1 -1
- package/lib/common/log.js +24 -1
- package/lib/common/log.js.map +1 -1
- package/lib/common/npm.js +13 -13
- package/lib/common/npm.js.map +1 -1
- package/lib/external/index.js +426 -230
- package/lib/inject.js +24 -1
- package/lib/inject.js.map +1 -1
- package/lib/{common/clients → npm-clients}/bun.js +5 -5
- package/lib/npm-clients/bun.js.map +1 -0
- package/lib/{common/clients → npm-clients}/index.js +31 -8
- package/lib/npm-clients/index.js.map +1 -0
- package/lib/{common/clients → npm-clients}/lerna.js +4 -4
- package/lib/npm-clients/lerna.js.map +1 -0
- package/lib/{common/clients → npm-clients}/npm.js +4 -4
- package/lib/npm-clients/npm.js.map +1 -0
- package/lib/{common/clients → npm-clients}/pnp.js +4 -4
- package/lib/npm-clients/pnp.js.map +1 -0
- package/lib/{common/clients → npm-clients}/pnpm.js +4 -4
- package/lib/npm-clients/pnpm.js.map +1 -0
- package/lib/{common/clients → npm-clients}/rush.js +5 -5
- package/lib/npm-clients/rush.js.map +1 -0
- package/lib/{common/clients → npm-clients}/yarn.js +4 -4
- package/lib/npm-clients/yarn.js.map +1 -0
- package/package.json +2 -2
- package/src/apps/build-pilet.test.ts +1 -0
- package/src/apps/build-piral.test.ts +19 -12
- package/src/apps/new-pilet.test.ts +120 -76
- package/src/apps/new-piral.test.ts +100 -77
- package/src/apps/pack-pilet.test.ts +2 -3
- package/src/apps/upgrade-pilet.test.ts +1 -0
- package/src/bundler.test.ts +8 -7
- package/src/bundler.ts +2 -1
- package/src/cli.ts +1 -1
- package/src/common/archive.test.ts +10 -7
- package/src/common/browser.test.ts +2 -1
- package/src/common/compatibility.test.ts +1 -0
- package/src/common/envs.test.ts +2 -1
- package/src/common/hash.test.ts +1 -0
- package/src/common/http.test.ts +73 -70
- package/src/common/importmap.test.ts +3 -2
- package/src/common/info.test.ts +1 -0
- package/src/common/interactive.test.ts +2 -1
- package/src/common/io.ts +1 -1
- package/src/common/merge.test.ts +1 -0
- package/src/common/npm.test.ts +35 -37
- package/src/common/npm.ts +1 -1
- package/src/common/pack.test.ts +11 -10
- package/src/common/package.test.ts +131 -92
- package/src/common/parallel.test.ts +1 -0
- package/src/common/patches.test.ts +1 -0
- package/src/common/port.test.ts +2 -1
- package/src/common/rules.test.ts +4 -3
- package/src/common/url.test.ts +1 -0
- package/src/common/utils.test.ts +1 -0
- package/src/common/version.test.ts +1 -0
- package/src/external/index.test.ts +1 -0
- package/src/helpers.test.ts +1 -0
- package/src/injectors/pilet-injector.test.ts +6 -5
- package/src/injectors/piral-injector.test.ts +7 -6
- package/src/{common/clients → npm-clients}/bun.ts +5 -5
- package/src/{common/clients → npm-clients}/index.ts +1 -1
- package/src/{common/clients → npm-clients}/lerna.ts +4 -4
- package/src/{common/clients → npm-clients}/npm.ts +4 -4
- package/src/{common/clients → npm-clients}/pnp.ts +4 -4
- package/src/{common/clients → npm-clients}/pnpm.ts +4 -4
- package/src/{common/clients → npm-clients}/rush.ts +5 -5
- package/src/{common/clients → npm-clients}/yarn.ts +4 -4
- package/src/rules/pilet-has-externals-as-peers.test.ts +4 -3
- package/lib/common/clients/bun.js.map +0 -1
- package/lib/common/clients/index.js.map +0 -1
- package/lib/common/clients/lerna.js.map +0 -1
- package/lib/common/clients/npm.js.map +0 -1
- package/lib/common/clients/pnp.js.map +0 -1
- package/lib/common/clients/pnpm.js.map +0 -1
- package/lib/common/clients/rush.js.map +0 -1
- package/lib/common/clients/yarn.js.map +0 -1
- /package/lib/{common/clients → npm-clients}/bun.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/index.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/lerna.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/npm.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/pnp.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/pnpm.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/rush.d.ts +0 -0
- /package/lib/{common/clients → npm-clients}/yarn.d.ts +0 -0
package/src/common/npm.test.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { describe, it, expect, vitest } from 'vitest';
|
|
1
2
|
import { resolve } from 'path';
|
|
2
|
-
import { clients } from '
|
|
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
|
-
|
|
28
|
+
vitest.mock('child_process');
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
...
|
|
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
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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';
|
package/src/common/pack.test.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
-
readJson:
|
|
8
|
-
removeDirectory:
|
|
9
|
-
checkIsDirectory:
|
|
10
|
-
makeTempDir:
|
|
11
|
-
copy:
|
|
12
|
-
checkExists:
|
|
13
|
-
createDirectory:
|
|
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
|
-
|
|
17
|
-
createTgz:
|
|
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
|
-
|
|
5
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
48
|
-
|
|
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(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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(
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
106
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
});
|
package/src/common/port.test.ts
CHANGED
|
@@ -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
|
-
|
|
7
|
+
vitest.mock('../external', () => ({
|
|
7
8
|
ora() {
|
|
8
9
|
return {};
|
|
9
10
|
},
|
package/src/common/rules.test.ts
CHANGED
|
@@ -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:
|
|
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 =
|
|
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
|
-
|
|
21
|
+
vitest.clearAllMocks();
|
|
21
22
|
ruleSummary([], ['Warning!']);
|
|
22
23
|
expect(consoleSpy).toHaveBeenCalled();
|
|
23
24
|
});
|
package/src/common/url.test.ts
CHANGED
package/src/common/utils.test.ts
CHANGED
package/src/helpers.test.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
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
|
|
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,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
|
|