piral-cli 0.15.0-alpha.4311 → 0.15.0-alpha.4345
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/apps/new-pilet.d.ts +2 -2
- package/lib/apps/new-pilet.js.map +1 -1
- package/lib/apps/new-piral.d.ts +2 -2
- package/lib/apps/new-piral.js +3 -2
- package/lib/apps/new-piral.js.map +1 -1
- package/lib/apps/upgrade-pilet.js +1 -1
- package/lib/apps/upgrade-pilet.js.map +1 -1
- package/lib/commands.js +4 -4
- package/lib/commands.js.map +1 -1
- package/lib/common/config.d.ts +1 -2
- package/lib/common/config.js +1 -2
- package/lib/common/config.js.map +1 -1
- package/lib/common/emulator.js +1 -1
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/enums.d.ts +0 -4
- package/lib/common/enums.js +1 -6
- package/lib/common/enums.js.map +1 -1
- package/lib/common/language.d.ts +3 -13
- package/lib/common/language.js +46 -12
- package/lib/common/language.js.map +1 -1
- package/lib/common/package.d.ts +9 -3
- package/lib/common/package.js +11 -25
- package/lib/common/package.js.map +1 -1
- package/lib/common/scaffold.d.ts +12 -10
- package/lib/common/scaffold.js +6 -12
- package/lib/common/scaffold.js.map +1 -1
- package/lib/common/template.d.ts +1 -3
- package/lib/common/template.js +21 -47
- package/lib/common/template.js.map +1 -1
- package/lib/external/index.js +79 -79
- package/lib/helpers.d.ts +3 -5
- package/lib/helpers.js +2 -20
- package/lib/helpers.js.map +1 -1
- package/lib/injectors/pilet-injector.d.ts +1 -0
- package/lib/injectors/piral-injector.d.ts +1 -0
- package/lib/types/common.d.ts +0 -1
- package/lib/types/public.d.ts +1 -0
- package/package.json +3 -5
- package/src/apps/new-pilet.test.ts +9 -6
- package/src/apps/new-pilet.ts +1 -2
- package/src/apps/new-piral.test.ts +3 -6
- package/src/apps/new-piral.ts +5 -9
- package/src/apps/upgrade-pilet.ts +1 -2
- package/src/commands.ts +5 -6
- package/src/common/config.ts +2 -3
- package/src/common/emulator.ts +2 -2
- package/src/common/enums.ts +0 -5
- package/src/common/language.ts +59 -11
- package/src/common/npm.test.ts +14 -58
- package/src/common/package.test.ts +11 -3
- package/src/common/package.ts +20 -34
- package/src/common/scaffold.ts +8 -16
- package/src/common/template.ts +19 -40
- package/src/helpers.test.ts +2 -22
- package/src/helpers.ts +3 -23
- package/src/types/common.ts +0 -1
- package/src/types/public.ts +2 -0
- package/templates/piral-index.js.ejs +0 -16
package/src/common/template.ts
CHANGED
|
@@ -1,53 +1,32 @@
|
|
|
1
|
-
import { renderFile } from 'ejs';
|
|
2
|
-
import { writeFile } from 'fs';
|
|
3
|
-
import { resolve } from 'path';
|
|
4
|
-
import { log } from './log';
|
|
5
1
|
import { ForceOverwrite } from './enums';
|
|
6
2
|
import { createFileIfNotExists } from './io';
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
renderFile(file, data, (err, str) => {
|
|
12
|
-
if (err) {
|
|
13
|
-
reject(err);
|
|
14
|
-
} else {
|
|
15
|
-
resolve(str);
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
await new Promise<void>((resolve, reject) => {
|
|
20
|
-
writeFile(file, content, 'utf8', (err) => {
|
|
21
|
-
if (err) {
|
|
22
|
-
reject(err);
|
|
23
|
-
} else {
|
|
24
|
-
resolve();
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
}
|
|
4
|
+
function fillTemplate(data: any = {}) {
|
|
5
|
+
return `if (process.env.NODE_ENV === 'test') {
|
|
6
|
+
// behavior for the test environment, we'll try to make it work
|
|
29
7
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
8
|
+
if (typeof window !== 'undefined') {
|
|
9
|
+
require('./${data.outFile}');
|
|
10
|
+
const ctx = window['dbg:piral'];
|
|
11
|
+
const dependencies = (ctx && ctx.pilets && ctx.pilets.getDependencies({})) || {};
|
|
12
|
+
module.exports = dependencies['${data.name}'] || {};
|
|
13
|
+
} else {
|
|
14
|
+
console.error('Your test environment does not define "window". Please make sure to provide a proper environment.');
|
|
15
|
+
module.exports = {};
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
// under "normal" circumstances disallow such an import
|
|
19
|
+
throw new Error("This file should not be included anywhere. Usually, this means you've imported the Piral instance directly.");
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
42
22
|
}
|
|
43
23
|
|
|
44
|
-
export async function
|
|
45
|
-
prefix: string,
|
|
24
|
+
export async function createPiralStubIndexIfNotExists(
|
|
46
25
|
targetDir: string,
|
|
47
26
|
fileName: string,
|
|
48
27
|
forceOverwrite?: ForceOverwrite,
|
|
49
28
|
data?: any,
|
|
50
29
|
) {
|
|
51
|
-
const content =
|
|
30
|
+
const content = fillTemplate(data);
|
|
52
31
|
await createFileIfNotExists(targetDir, fileName, content, forceOverwrite);
|
|
53
32
|
}
|
package/src/helpers.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { keyOfForceOverwrite,
|
|
2
|
-
import { ForceOverwrite
|
|
1
|
+
import { keyOfForceOverwrite, valueOfForceOverwrite } from './helpers';
|
|
2
|
+
import { ForceOverwrite } from './common/enums';
|
|
3
3
|
|
|
4
4
|
describe('Piral CLI Command Helpers Module', () => {
|
|
5
5
|
it('correct value of keyOfForceOverwrite results in same key', () => {
|
|
@@ -12,16 +12,6 @@ describe('Piral CLI Command Helpers Module', () => {
|
|
|
12
12
|
expect(result).toBe('no');
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
it('correct value of keyOfPiletLanguage results in same key', () => {
|
|
16
|
-
const result = keyOfSourceLanguage(SourceLanguage.ts);
|
|
17
|
-
expect(result).toBe('ts');
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('incorrect value of keyOfPiletLanguage results in key for TS', () => {
|
|
21
|
-
const result = keyOfSourceLanguage(5);
|
|
22
|
-
expect(result).toBe('ts');
|
|
23
|
-
});
|
|
24
|
-
|
|
25
15
|
it('correct key of valueOfForceOverwrite results in same value', () => {
|
|
26
16
|
const result = valueOfForceOverwrite('prompt');
|
|
27
17
|
expect(result).toBe(ForceOverwrite.prompt);
|
|
@@ -31,14 +21,4 @@ describe('Piral CLI Command Helpers Module', () => {
|
|
|
31
21
|
const result = valueOfForceOverwrite('foo');
|
|
32
22
|
expect(result).toBe(ForceOverwrite.no);
|
|
33
23
|
});
|
|
34
|
-
|
|
35
|
-
it('correct key of valueOfPiletLanguage results in same value', () => {
|
|
36
|
-
const result = valueOfSourceLanguage('ts');
|
|
37
|
-
expect(result).toBe(SourceLanguage.ts);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('incorrect key of valueOfPiletLanguage results in value for TS', () => {
|
|
41
|
-
const result = valueOfSourceLanguage('foo');
|
|
42
|
-
expect(result).toBe(SourceLanguage.ts);
|
|
43
|
-
});
|
|
44
24
|
});
|
package/src/helpers.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ForceOverwrite
|
|
1
|
+
import { ForceOverwrite } from './common/enums';
|
|
2
2
|
import { bundlerNames, frameworkLibs } from './common/constants';
|
|
3
3
|
import type {
|
|
4
4
|
Framework,
|
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
PiralBuildType,
|
|
9
9
|
PiletBuildType,
|
|
10
10
|
PiletPublishScheme,
|
|
11
|
+
SourceLanguage,
|
|
11
12
|
} from './types';
|
|
12
13
|
|
|
13
14
|
export const schemaKeys: Array<PiletSchemaVersion> = ['v0', 'v1', 'v2', 'none'];
|
|
@@ -16,6 +17,7 @@ export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
|
|
|
16
17
|
export const piralBuildTypeKeys: Array<PiralBuildType> = ['all', 'release', 'emulator', 'emulator-sources'];
|
|
17
18
|
export const piletBuildTypeKeys: Array<PiletBuildType> = ['default', 'standalone', 'manifest'];
|
|
18
19
|
export const clientTypeKeys: Array<NpmClientType> = ['npm', 'pnpm', 'pnp', 'yarn', 'lerna', 'rush'];
|
|
20
|
+
export const sourceLanguageKeys: Array<SourceLanguage> = ['ts', 'js'];
|
|
19
21
|
export const bundlerKeys: Array<string> = ['none', ...bundlerNames];
|
|
20
22
|
export const availableBundlers: Array<string> = [];
|
|
21
23
|
export const availableReleaseProviders: Array<string> = [];
|
|
@@ -41,25 +43,3 @@ export function keyOfForceOverwrite(value: ForceOverwrite) {
|
|
|
41
43
|
|
|
42
44
|
return forceOverwriteKeys[0];
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
export const sourceLanguageKeys = Object.keys(SourceLanguage).filter((m) => typeof SourceLanguage[m] === 'number');
|
|
46
|
-
|
|
47
|
-
export function valueOfSourceLanguage(key: string): SourceLanguage {
|
|
48
|
-
for (const piletLanguageKey of sourceLanguageKeys) {
|
|
49
|
-
if (piletLanguageKey === key) {
|
|
50
|
-
return SourceLanguage[piletLanguageKey];
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return SourceLanguage.ts;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
export function keyOfSourceLanguage(value: SourceLanguage) {
|
|
58
|
-
for (const piletLanguageKey of sourceLanguageKeys) {
|
|
59
|
-
if (SourceLanguage[piletLanguageKey] === value) {
|
|
60
|
-
return piletLanguageKey;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return sourceLanguageKeys[0];
|
|
65
|
-
}
|
package/src/types/common.ts
CHANGED
package/src/types/public.ts
CHANGED
|
@@ -219,6 +219,8 @@ export interface BundlerDefinition {
|
|
|
219
219
|
|
|
220
220
|
export type PiletSchemaVersion = 'none' | 'v0' | 'v1' | 'v2';
|
|
221
221
|
|
|
222
|
+
export type SourceLanguage = 'js' | 'ts';
|
|
223
|
+
|
|
222
224
|
export type PiletPublishScheme = 'none' | 'digest' | 'bearer' | 'basic';
|
|
223
225
|
|
|
224
226
|
export type PiletPublishSource = 'local' | 'npm' | 'remote';
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
if (process.env.NODE_ENV === 'test') {
|
|
2
|
-
// behavior for the test environment, we'll try to make it work
|
|
3
|
-
|
|
4
|
-
if (typeof window !== 'undefined') {
|
|
5
|
-
require('./<%- outFile %>');
|
|
6
|
-
const ctx = window['dbg:piral'];
|
|
7
|
-
const dependencies = (ctx && ctx.pilets && ctx.pilets.getDependencies({})) || {};
|
|
8
|
-
module.exports = dependencies['<%- name %>'] || {};
|
|
9
|
-
} else {
|
|
10
|
-
console.error('Your test environment does not define "window". Please make sure to provide a proper environment.');
|
|
11
|
-
module.exports = {};
|
|
12
|
-
}
|
|
13
|
-
} else {
|
|
14
|
-
// under "normal" circumstances disallow such an import
|
|
15
|
-
throw new Error("This file should not be included anywhere. Usually, this means you've imported the Piral instance directly.");
|
|
16
|
-
}
|