piral-cli 1.5.0-beta.6658 → 1.5.0-beta.6685
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/api.d.ts +1 -2
- package/lib/api.js +1 -18
- package/lib/api.js.map +1 -1
- package/lib/apps/build-pilet.js +14 -37
- package/lib/apps/build-pilet.js.map +1 -1
- package/lib/apps/build-piral.js +29 -104
- package/lib/apps/build-piral.js.map +1 -1
- package/lib/apps/debug-pilet.js +8 -2
- package/lib/apps/debug-pilet.js.map +1 -1
- package/lib/apps/debug-piral.js +5 -1
- package/lib/apps/debug-piral.js.map +1 -1
- package/lib/apps/publish-pilet.d.ts +11 -2
- package/lib/apps/publish-pilet.js +16 -43
- package/lib/apps/publish-pilet.js.map +1 -1
- package/lib/apps/publish-piral.d.ts +37 -7
- package/lib/apps/publish-piral.js +62 -47
- package/lib/apps/publish-piral.js.map +1 -1
- package/lib/build/bundler-calls.js +4 -1
- package/lib/build/bundler-calls.js.map +1 -1
- package/lib/commands.js +31 -12
- package/lib/commands.js.map +1 -1
- package/lib/common/constants.d.ts +7 -0
- package/lib/common/constants.js +8 -1
- package/lib/common/constants.js.map +1 -1
- package/lib/common/emulator.js +1 -1
- package/lib/common/emulator.js.map +1 -1
- package/lib/common/http.d.ts +3 -3
- package/lib/common/http.js.map +1 -1
- package/lib/common/index.d.ts +3 -0
- package/lib/common/index.js +3 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/interactive.d.ts +2 -2
- package/lib/common/pilet.d.ts +31 -0
- package/lib/common/pilet.js +79 -0
- package/lib/common/pilet.js.map +1 -0
- package/lib/common/piral.d.ts +35 -0
- package/lib/common/piral.js +125 -0
- package/lib/common/piral.js.map +1 -0
- package/lib/common/release.d.ts +4 -0
- package/lib/common/release.js +43 -0
- package/lib/common/release.js.map +1 -0
- package/lib/helpers.d.ts +2 -2
- package/lib/helpers.js.map +1 -1
- package/lib/messages.d.ts +19 -0
- package/lib/messages.js +23 -1
- package/lib/messages.js.map +1 -1
- package/lib/platforms/web.js +20 -7
- package/lib/platforms/web.js.map +1 -1
- package/lib/types/common.d.ts +8 -4
- package/lib/types/public.d.ts +2 -3
- package/package.json +2 -2
- package/src/api.ts +0 -17
- package/src/apps/build-pilet.ts +17 -59
- package/src/apps/build-piral.ts +37 -140
- package/src/apps/debug-pilet.ts +10 -3
- package/src/apps/debug-piral.ts +6 -2
- package/src/apps/publish-pilet.ts +35 -62
- package/src/apps/publish-piral.ts +150 -80
- package/src/build/bundler-calls.ts +4 -1
- package/src/commands.ts +34 -15
- package/src/common/constants.ts +7 -0
- package/src/common/emulator.ts +2 -2
- package/src/common/http.ts +3 -3
- package/src/common/index.ts +3 -0
- package/src/common/interactive.ts +2 -2
- package/src/common/pilet.ts +140 -0
- package/src/common/piral.ts +227 -0
- package/src/common/release.ts +62 -0
- package/src/helpers.ts +2 -2
- package/src/messages.ts +22 -0
- package/src/platforms/web.ts +25 -8
- package/src/types/common.ts +9 -4
- package/src/types/public.ts +2 -3
- package/lib/release.d.ts +0 -7
- package/lib/release.js +0 -67
- package/lib/release.js.map +0 -1
- package/src/release.ts +0 -91
package/src/apps/debug-piral.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname, join, resolve } from 'path';
|
|
2
2
|
import { callPiralDebug } from '../bundler';
|
|
3
|
-
import { LogLevels } from '../types';
|
|
3
|
+
import { LogLevels, NetworkSpec } from '../types';
|
|
4
4
|
import {
|
|
5
5
|
retrievePiletsInfo,
|
|
6
6
|
retrievePiralRoot,
|
|
@@ -124,6 +124,10 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
124
124
|
} = options;
|
|
125
125
|
const publicUrl = normalizePublicUrl(originalPublicUrl);
|
|
126
126
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
127
|
+
const network: NetworkSpec = {
|
|
128
|
+
port: originalPort,
|
|
129
|
+
type: 'proposed',
|
|
130
|
+
};
|
|
127
131
|
setLogLevel(logLevel);
|
|
128
132
|
|
|
129
133
|
await hooks.onBegin?.({ options, fullBase });
|
|
@@ -187,7 +191,7 @@ export async function debugPiral(baseDir = process.cwd(), options: DebugPiralOpt
|
|
|
187
191
|
fullBase,
|
|
188
192
|
hooks,
|
|
189
193
|
open,
|
|
190
|
-
|
|
194
|
+
network,
|
|
191
195
|
publicUrl,
|
|
192
196
|
root,
|
|
193
197
|
targetDir,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { relative, dirname, basename, resolve
|
|
2
|
-
import {
|
|
3
|
-
import { LogLevels, PiletSchemaVersion, PiletPublishSource, PiletPublishScheme } from '../types';
|
|
1
|
+
import { relative, dirname, basename, resolve } from 'path';
|
|
2
|
+
import { LogLevels, PiletSchemaVersion, PiletPublishSource, PublishScheme } from '../types';
|
|
4
3
|
import {
|
|
5
4
|
postFile,
|
|
6
5
|
readBinary,
|
|
@@ -16,11 +15,7 @@ import {
|
|
|
16
15
|
findNpmTarball,
|
|
17
16
|
downloadFile,
|
|
18
17
|
matchAnyPilet,
|
|
19
|
-
|
|
20
|
-
removeDirectory,
|
|
21
|
-
logInfo,
|
|
22
|
-
combinePiletExternals,
|
|
23
|
-
defaultSchemaVersion,
|
|
18
|
+
triggerBuildPilet,
|
|
24
19
|
} from '../common';
|
|
25
20
|
|
|
26
21
|
export interface PublishPiletOptions {
|
|
@@ -92,12 +87,22 @@ export interface PublishPiletOptions {
|
|
|
92
87
|
/**
|
|
93
88
|
* Sets the authorization scheme to use.
|
|
94
89
|
*/
|
|
95
|
-
mode?:
|
|
90
|
+
mode?: PublishScheme;
|
|
96
91
|
|
|
97
92
|
/**
|
|
98
93
|
* Additional arguments for a specific bundler.
|
|
99
94
|
*/
|
|
100
95
|
_?: Record<string, any>;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Hooks to be triggered at various stages.
|
|
99
|
+
*/
|
|
100
|
+
hooks?: {
|
|
101
|
+
beforeBuild?(e: any): Promise<void>;
|
|
102
|
+
afterBuild?(e: any): Promise<void>;
|
|
103
|
+
beforeDeclaration?(e: any): Promise<void>;
|
|
104
|
+
afterDeclaration?(e: any): Promise<void>;
|
|
105
|
+
};
|
|
101
106
|
}
|
|
102
107
|
|
|
103
108
|
export const publishPiletDefaults: PublishPiletOptions = {
|
|
@@ -114,11 +119,6 @@ export const publishPiletDefaults: PublishPiletOptions = {
|
|
|
114
119
|
interactive: false,
|
|
115
120
|
};
|
|
116
121
|
|
|
117
|
-
function isSubDir(parent: string, dir: string) {
|
|
118
|
-
const rel = relative(parent, dir);
|
|
119
|
-
return rel && !rel.startsWith('..') && !isAbsolute(rel);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
122
|
async function getFiles(
|
|
123
123
|
baseDir: string,
|
|
124
124
|
sources: Array<string>,
|
|
@@ -129,6 +129,7 @@ async function getFiles(
|
|
|
129
129
|
bundlerName: string,
|
|
130
130
|
_?: Record<string, any>,
|
|
131
131
|
ca?: Buffer,
|
|
132
|
+
hooks?: PublishPiletOptions['hooks'],
|
|
132
133
|
): Promise<Array<string>> {
|
|
133
134
|
if (fresh) {
|
|
134
135
|
log('generalDebug_0003', 'Detected "--fresh". Trying to resolve the package.json.');
|
|
@@ -140,54 +141,25 @@ async function getFiles(
|
|
|
140
141
|
|
|
141
142
|
return await Promise.all(
|
|
142
143
|
allEntries.map(async (entryModule) => {
|
|
143
|
-
const targetDir = dirname(entryModule);
|
|
144
|
-
|
|
145
144
|
progress('Triggering pilet build ...');
|
|
146
|
-
const { root, piletPackage, importmap, peerDependencies, peerModules, apps, schema } = await retrievePiletData(
|
|
147
|
-
targetDir,
|
|
148
|
-
);
|
|
149
|
-
const schemaVersion = originalSchemaVersion || schema || config.schemaVersion || defaultSchemaVersion;
|
|
150
|
-
const piralInstances = apps.map((m) => m.appPackage.name);
|
|
151
|
-
const defaultOutput = 'dist/index.js';
|
|
152
|
-
const { main = defaultOutput, name = 'pilet' } = piletPackage;
|
|
153
|
-
const propDest = resolve(root, main);
|
|
154
|
-
const propDestDir = dirname(propDest);
|
|
155
|
-
log('generalDebug_0003', `Pilet "${name}" is supposed to generate artifact in "${propDest}".`);
|
|
156
|
-
const usePropDest = propDestDir !== root && propDestDir !== targetDir && isSubDir(root, propDest);
|
|
157
|
-
const dest = usePropDest ? propDest : resolve(root, defaultOutput);
|
|
158
|
-
log('generalDebug_0003', `Pilet "${name}" is generating artifact in "${dest}".`);
|
|
159
|
-
const outDir = dirname(dest);
|
|
160
|
-
const outFile = basename(dest);
|
|
161
|
-
const externals = combinePiletExternals(piralInstances, peerDependencies, peerModules, importmap);
|
|
162
|
-
log('generalDebug_0003', `Pilet "${name}" uses externals: ${externals.join(', ')}.`);
|
|
163
|
-
|
|
164
|
-
progress('Removing output directory ...');
|
|
165
|
-
await removeDirectory(outDir);
|
|
166
|
-
|
|
167
|
-
logInfo('Bundle pilet ...');
|
|
168
|
-
await callPiletBuild(
|
|
169
|
-
{
|
|
170
|
-
root,
|
|
171
|
-
piralInstances,
|
|
172
|
-
optimizeModules: false,
|
|
173
|
-
sourceMaps: true,
|
|
174
|
-
watch: false,
|
|
175
|
-
contentHash: true,
|
|
176
|
-
minify: true,
|
|
177
|
-
externals,
|
|
178
|
-
targetDir,
|
|
179
|
-
importmap,
|
|
180
|
-
outFile,
|
|
181
|
-
outDir,
|
|
182
|
-
entryModule: `./${relative(root, entryModule)}`,
|
|
183
|
-
logLevel,
|
|
184
|
-
version: schemaVersion,
|
|
185
|
-
ignored: [],
|
|
186
|
-
_,
|
|
187
|
-
},
|
|
188
|
-
bundlerName,
|
|
189
|
-
);
|
|
190
145
|
|
|
146
|
+
const { root, piletPackage } = await triggerBuildPilet({
|
|
147
|
+
_,
|
|
148
|
+
bundlerName,
|
|
149
|
+
entryModule,
|
|
150
|
+
fresh,
|
|
151
|
+
logLevel,
|
|
152
|
+
originalSchemaVersion,
|
|
153
|
+
watch: false,
|
|
154
|
+
optimizeModules: false,
|
|
155
|
+
sourceMaps: true,
|
|
156
|
+
declaration: true,
|
|
157
|
+
contentHash: true,
|
|
158
|
+
minify: true,
|
|
159
|
+
hooks,
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const name = piletPackage.name;
|
|
191
163
|
log('generalDebug_0003', `Pilet "${name}" built successfully!`);
|
|
192
164
|
progress('Triggering pilet pack ...');
|
|
193
165
|
|
|
@@ -237,6 +209,7 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
|
|
|
237
209
|
mode = publishPiletDefaults.mode,
|
|
238
210
|
interactive = publishPiletDefaults.interactive,
|
|
239
211
|
_ = {},
|
|
212
|
+
hooks = {},
|
|
240
213
|
bundlerName,
|
|
241
214
|
} = options;
|
|
242
215
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
@@ -259,7 +232,7 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
|
|
|
259
232
|
|
|
260
233
|
log('generalDebug_0003', 'Getting the tgz files ...');
|
|
261
234
|
const sources = Array.isArray(source) ? source : [source];
|
|
262
|
-
const files = await getFiles(fullBase, sources, from, fresh, schemaVersion, logLevel, bundlerName, _, ca);
|
|
235
|
+
const files = await getFiles(fullBase, sources, from, fresh, schemaVersion, logLevel, bundlerName, _, ca, hooks);
|
|
263
236
|
const successfulUploads: Array<string> = [];
|
|
264
237
|
log('generalDebug_0003', 'Received available tgz files.');
|
|
265
238
|
|
|
@@ -275,7 +248,7 @@ export async function publishPilet(baseDir = process.cwd(), options: PublishPile
|
|
|
275
248
|
const content = await readBinary(fullBase, fileName);
|
|
276
249
|
|
|
277
250
|
if (content) {
|
|
278
|
-
progress(`Publishing "%s" ...`, file, url);
|
|
251
|
+
progress(`Publishing "%s" to "%s" ...`, file, url);
|
|
279
252
|
const result = await postFile(url, mode, apiKey, content, fields, headers, ca, interactive);
|
|
280
253
|
|
|
281
254
|
if (result.success) {
|
|
@@ -1,16 +1,26 @@
|
|
|
1
|
-
import { resolve } from 'path';
|
|
2
|
-
import {
|
|
3
|
-
import { LogLevels, PiralBuildType } from '../types';
|
|
1
|
+
import { basename, dirname, resolve } from 'path';
|
|
2
|
+
import { LogLevels, PublishScheme } from '../types';
|
|
4
3
|
import {
|
|
5
4
|
setLogLevel,
|
|
6
5
|
progress,
|
|
7
6
|
checkExists,
|
|
8
7
|
fail,
|
|
9
8
|
logDone,
|
|
10
|
-
logReset,
|
|
11
|
-
publishNpmPackage,
|
|
12
|
-
matchFiles,
|
|
13
9
|
log,
|
|
10
|
+
config,
|
|
11
|
+
readBinary,
|
|
12
|
+
emulatorName,
|
|
13
|
+
emulatorJson,
|
|
14
|
+
publishWebsiteEmulator,
|
|
15
|
+
matchFiles,
|
|
16
|
+
readJson,
|
|
17
|
+
triggerBuildEmulator,
|
|
18
|
+
logReset,
|
|
19
|
+
emulatorWebsiteName,
|
|
20
|
+
retrievePiralRoot,
|
|
21
|
+
emulatorPackageName,
|
|
22
|
+
retrievePiletsInfo,
|
|
23
|
+
validateSharedDependencies,
|
|
14
24
|
} from '../common';
|
|
15
25
|
|
|
16
26
|
export interface PublishPiralOptions {
|
|
@@ -19,15 +29,36 @@ export interface PublishPiralOptions {
|
|
|
19
29
|
*/
|
|
20
30
|
source?: string;
|
|
21
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Sets the URL of the feed service to deploy to.
|
|
34
|
+
*/
|
|
35
|
+
url?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Sets the API key to use.
|
|
39
|
+
*/
|
|
40
|
+
apiKey?: string;
|
|
41
|
+
|
|
22
42
|
/**
|
|
23
43
|
* Sets the log level to use (1-5).
|
|
24
44
|
*/
|
|
25
45
|
logLevel?: LogLevels;
|
|
26
46
|
|
|
27
47
|
/**
|
|
28
|
-
*
|
|
48
|
+
* Specifies if the Piral instance should be built before publishing.
|
|
49
|
+
* If yes, then the tarball is created from fresh build artifacts.
|
|
50
|
+
*/
|
|
51
|
+
fresh?: boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Defines a custom certificate for the feed service.
|
|
29
55
|
*/
|
|
30
|
-
|
|
56
|
+
cert?: string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Places additional headers that should be posted to the feed service.
|
|
60
|
+
*/
|
|
61
|
+
headers?: Record<string, string>;
|
|
31
62
|
|
|
32
63
|
/**
|
|
33
64
|
* Defines if authorization tokens can be retrieved interactively.
|
|
@@ -35,104 +66,143 @@ export interface PublishPiralOptions {
|
|
|
35
66
|
interactive?: boolean;
|
|
36
67
|
|
|
37
68
|
/**
|
|
38
|
-
*
|
|
69
|
+
* Sets the bundler to use for building, if any specific.
|
|
39
70
|
*/
|
|
40
|
-
|
|
71
|
+
bundlerName?: string;
|
|
41
72
|
|
|
42
73
|
/**
|
|
43
|
-
*
|
|
74
|
+
* Sets the authorization scheme to use.
|
|
44
75
|
*/
|
|
45
|
-
|
|
76
|
+
mode?: PublishScheme;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Additional arguments for a specific bundler.
|
|
80
|
+
*/
|
|
81
|
+
_?: Record<string, any>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Hooks to be triggered at various stages.
|
|
85
|
+
*/
|
|
86
|
+
hooks?: {
|
|
87
|
+
beforeEmulator?(e: any): Promise<void>;
|
|
88
|
+
afterEmulator?(e: any): Promise<void>;
|
|
89
|
+
beforePackage?(e: any): Promise<void>;
|
|
90
|
+
afterPackage?(e: any): Promise<void>;
|
|
91
|
+
};
|
|
46
92
|
}
|
|
47
93
|
|
|
48
94
|
export const publishPiralDefaults: PublishPiralOptions = {
|
|
49
95
|
source: './dist',
|
|
50
96
|
logLevel: LogLevels.info,
|
|
51
|
-
|
|
52
|
-
provider: 'none',
|
|
53
|
-
opts: {},
|
|
97
|
+
url: undefined,
|
|
54
98
|
interactive: false,
|
|
99
|
+
apiKey: undefined,
|
|
100
|
+
fresh: false,
|
|
101
|
+
cert: undefined,
|
|
102
|
+
mode: 'basic',
|
|
103
|
+
headers: {},
|
|
55
104
|
};
|
|
56
105
|
|
|
57
|
-
async function publishEmulator(
|
|
58
|
-
baseDir: string,
|
|
59
|
-
source: string,
|
|
60
|
-
args: Record<string, string> = {},
|
|
61
|
-
interactive = false,
|
|
62
|
-
) {
|
|
63
|
-
const type = 'emulator';
|
|
64
|
-
const directory = resolve(baseDir, source, type);
|
|
65
|
-
const exists = await checkExists(directory);
|
|
66
|
-
|
|
67
|
-
if (!exists) {
|
|
68
|
-
fail('publishDirectoryMissing_0110', directory);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const files = await matchFiles(directory, '*.tgz');
|
|
72
|
-
log('generalDebug_0003', `Found ${files.length} in "${directory}": ${files.join(', ')}`);
|
|
73
|
-
|
|
74
|
-
if (files.length !== 1) {
|
|
75
|
-
fail('publishEmulatorFilesUnexpected_0111', directory);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const [file] = files;
|
|
79
|
-
const flags = Object.keys(args).reduce((p, c) => {
|
|
80
|
-
p.push(`--${c}`, args[c]);
|
|
81
|
-
return p;
|
|
82
|
-
}, [] as Array<string>);
|
|
83
|
-
|
|
84
|
-
await publishNpmPackage(directory, file, flags, interactive);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
async function publishRelease(
|
|
88
|
-
baseDir: string,
|
|
89
|
-
source: string,
|
|
90
|
-
providerName: string,
|
|
91
|
-
args: Record<string, string> = {},
|
|
92
|
-
interactive = false,
|
|
93
|
-
) {
|
|
94
|
-
const type = 'release';
|
|
95
|
-
const directory = resolve(baseDir, source, type);
|
|
96
|
-
const exists = await checkExists(directory);
|
|
97
|
-
|
|
98
|
-
if (!exists) {
|
|
99
|
-
fail('publishDirectoryMissing_0110', directory);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const files = await matchFiles(directory, '**/*');
|
|
103
|
-
log('generalDebug_0003', `Found ${files.length} in "${directory}": ${files.join(', ')}`);
|
|
104
|
-
await publishArtifacts(providerName, directory, files, args, interactive);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
106
|
export async function publishPiral(baseDir = process.cwd(), options: PublishPiralOptions = {}) {
|
|
108
107
|
const {
|
|
109
108
|
source = publishPiralDefaults.source,
|
|
110
|
-
type = publishPiralDefaults.type,
|
|
111
109
|
logLevel = publishPiralDefaults.logLevel,
|
|
112
|
-
opts = publishPiralDefaults.opts,
|
|
113
|
-
provider = publishPiralDefaults.provider,
|
|
114
110
|
interactive = publishPiralDefaults.interactive,
|
|
111
|
+
fresh = publishPiralDefaults.fresh,
|
|
112
|
+
url = config.url ?? publishPiralDefaults.url,
|
|
113
|
+
apiKey = config.apiKeys?.[url] ?? config.apiKey ?? publishPiralDefaults.apiKey,
|
|
114
|
+
cert = config.cert ?? publishPiralDefaults.cert,
|
|
115
|
+
headers = publishPiralDefaults.headers,
|
|
116
|
+
mode = publishPiralDefaults.mode,
|
|
117
|
+
_ = {},
|
|
118
|
+
hooks = {},
|
|
119
|
+
bundlerName,
|
|
115
120
|
} = options;
|
|
116
121
|
const fullBase = resolve(process.cwd(), baseDir);
|
|
117
122
|
setLogLevel(logLevel);
|
|
123
|
+
progress('Reading configuration ...');
|
|
118
124
|
|
|
119
|
-
if (
|
|
120
|
-
fail('
|
|
125
|
+
if (!url) {
|
|
126
|
+
fail('missingPiletFeedUrl_0060');
|
|
121
127
|
}
|
|
122
128
|
|
|
123
|
-
|
|
129
|
+
log('generalDebug_0003', 'Checking if certificate exists.');
|
|
130
|
+
let ca: Buffer = undefined;
|
|
124
131
|
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
if (await checkExists(cert)) {
|
|
133
|
+
const dir = dirname(cert);
|
|
134
|
+
const file = basename(cert);
|
|
135
|
+
log('generalDebug_0003', `Reading certificate file "${file}" from "${dir}".`);
|
|
136
|
+
ca = await readBinary(dir, file);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
log('generalDebug_0003', 'Getting the files ...');
|
|
140
|
+
const entryFiles = await retrievePiralRoot(fullBase, './');
|
|
141
|
+
const {
|
|
142
|
+
name,
|
|
143
|
+
root,
|
|
144
|
+
ignored,
|
|
145
|
+
externals,
|
|
146
|
+
scripts,
|
|
147
|
+
emulator = emulatorPackageName,
|
|
148
|
+
} = await retrievePiletsInfo(entryFiles);
|
|
149
|
+
|
|
150
|
+
if (emulator !== emulatorWebsiteName) {
|
|
151
|
+
fail('generalError_0002', `Currently only the "${emulatorWebsiteName}" option is supported.`);
|
|
130
152
|
}
|
|
153
|
+
|
|
154
|
+
const emulatorDir = resolve(fullBase, source, emulatorName);
|
|
155
|
+
|
|
156
|
+
if (fresh) {
|
|
157
|
+
const piralInstances = [name];
|
|
158
|
+
|
|
159
|
+
validateSharedDependencies(externals);
|
|
160
|
+
|
|
161
|
+
await triggerBuildEmulator({
|
|
162
|
+
root,
|
|
163
|
+
logLevel,
|
|
164
|
+
bundlerName,
|
|
165
|
+
emulatorType: emulatorWebsiteName,
|
|
166
|
+
hooks,
|
|
167
|
+
targetDir: emulatorDir,
|
|
168
|
+
ignored,
|
|
169
|
+
externals,
|
|
170
|
+
entryFiles,
|
|
171
|
+
piralInstances,
|
|
172
|
+
optimizeModules: true,
|
|
173
|
+
sourceMaps: true,
|
|
174
|
+
watch: false,
|
|
175
|
+
scripts,
|
|
176
|
+
contentHash: true,
|
|
177
|
+
outFile: 'index.html',
|
|
178
|
+
_,
|
|
179
|
+
});
|
|
131
180
|
|
|
132
|
-
if (type !== 'emulator') {
|
|
133
|
-
progress('Publishing release files ...');
|
|
134
|
-
await publishRelease(fullBase, source, provider, opts, interactive);
|
|
135
|
-
logDone(`Successfully published release.`);
|
|
136
181
|
logReset();
|
|
137
182
|
}
|
|
183
|
+
|
|
184
|
+
const { version } = await readJson(emulatorDir, emulatorJson);
|
|
185
|
+
|
|
186
|
+
if (!version) {
|
|
187
|
+
fail('missingEmulatorWebsite_0130', emulatorDir);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
log('generalInfo_0000', `Using feed service "${url}".`);
|
|
191
|
+
|
|
192
|
+
const files = await matchFiles(emulatorDir, '**/*');
|
|
193
|
+
|
|
194
|
+
progress(`Publishing emulator to "%s" ...`, url);
|
|
195
|
+
const result = await publishWebsiteEmulator(version, url, apiKey, mode, emulatorDir, files, interactive, headers, ca);
|
|
196
|
+
|
|
197
|
+
if (!result.success) {
|
|
198
|
+
fail('failedUploading_0064');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (result.response) {
|
|
202
|
+
log('httpPostResponse_0067', result);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
progress(`Published successfully!`);
|
|
206
|
+
|
|
207
|
+
logDone(`Emulator published successfully!`);
|
|
138
208
|
}
|
package/src/commands.ts
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
PiletPublishSource,
|
|
25
25
|
PiletSchemaVersion,
|
|
26
26
|
PiletBuildType,
|
|
27
|
-
|
|
27
|
+
PublishScheme,
|
|
28
28
|
SourceLanguage,
|
|
29
29
|
} from './types';
|
|
30
30
|
|
|
@@ -196,25 +196,39 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
196
196
|
alias: ['release-piral', 'release'],
|
|
197
197
|
description: 'Publishes Piral instance build artifacts.',
|
|
198
198
|
arguments: ['[source]'],
|
|
199
|
-
|
|
199
|
+
// "any" due to https://github.com/microsoft/TypeScript/issues/28663 [artifical N = 50]
|
|
200
|
+
flags(argv: any) {
|
|
200
201
|
return argv
|
|
201
202
|
.positional('source', {
|
|
202
203
|
type: 'string',
|
|
203
204
|
describe: 'Sets the previously used output directory to publish.',
|
|
204
205
|
default: apps.publishPiralDefaults.source,
|
|
205
206
|
})
|
|
207
|
+
.string('url')
|
|
208
|
+
.describe('url', 'Sets the explicit URL where to publish the emulator to.')
|
|
209
|
+
.default('url', apps.publishPiralDefaults.url)
|
|
210
|
+
.string('api-key')
|
|
211
|
+
.describe('api-key', 'Sets the potential API key to send to the service.')
|
|
212
|
+
.default('api-key', apps.publishPiralDefaults.apiKey)
|
|
213
|
+
.string('ca-cert')
|
|
214
|
+
.describe('ca-cert', 'Sets a custom certificate authority to use, if any.')
|
|
215
|
+
.default('ca-cert', apps.publishPiralDefaults.cert)
|
|
206
216
|
.number('log-level')
|
|
207
217
|
.describe('log-level', 'Sets the log level to use (1-5).')
|
|
208
218
|
.default('log-level', apps.publishPiralDefaults.logLevel)
|
|
209
|
-
.
|
|
210
|
-
.describe('
|
|
211
|
-
.default('
|
|
212
|
-
.choices('
|
|
213
|
-
.describe('
|
|
214
|
-
.default('
|
|
215
|
-
.
|
|
216
|
-
.
|
|
217
|
-
.
|
|
219
|
+
.boolean('fresh')
|
|
220
|
+
.describe('fresh', 'Performs a fresh build of the emulator website.')
|
|
221
|
+
.default('fresh', apps.publishPiralDefaults.fresh)
|
|
222
|
+
.choices('mode', publishModeKeys)
|
|
223
|
+
.describe('mode', 'Sets the authorization mode to use.')
|
|
224
|
+
.default('mode', apps.publishPiralDefaults.mode)
|
|
225
|
+
.alias('mode', 'auth-mode')
|
|
226
|
+
.choices('bundler', availableBundlers)
|
|
227
|
+
.describe('bundler', 'Sets the bundler to use.')
|
|
228
|
+
.default('bundler', availableBundlers[0])
|
|
229
|
+
.option('headers', undefined)
|
|
230
|
+
.describe('headers', 'Sets additional headers to be included in the feed service request.')
|
|
231
|
+
.default('headers', apps.publishPiralDefaults.headers)
|
|
218
232
|
.boolean('interactive')
|
|
219
233
|
.describe('interactive', 'Defines if authorization tokens can be retrieved interactively.')
|
|
220
234
|
.default('interactive', apps.publishPiralDefaults.interactive)
|
|
@@ -226,10 +240,15 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
226
240
|
return apps.publishPiral(args.base as string, {
|
|
227
241
|
source: args.source as string,
|
|
228
242
|
logLevel: args['log-level'] as LogLevels,
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
243
|
+
apiKey: args['api-key'] as string,
|
|
244
|
+
cert: args['ca-cert'] as string,
|
|
245
|
+
url: args.url as string,
|
|
232
246
|
interactive: args.interactive as boolean,
|
|
247
|
+
mode: args.mode as PublishScheme,
|
|
248
|
+
bundlerName: args.bundler as string,
|
|
249
|
+
fresh: args.fresh as boolean,
|
|
250
|
+
headers: args.headers as Record<string, string>,
|
|
251
|
+
_: args,
|
|
233
252
|
});
|
|
234
253
|
},
|
|
235
254
|
},
|
|
@@ -671,7 +690,7 @@ const allCommands: Array<ToolCommand<any>> = [
|
|
|
671
690
|
schemaVersion: args.schema as PiletSchemaVersion,
|
|
672
691
|
fields: args.fields as Record<string, string>,
|
|
673
692
|
headers: args.headers as Record<string, string>,
|
|
674
|
-
mode: args.mode as
|
|
693
|
+
mode: args.mode as PublishScheme,
|
|
675
694
|
interactive: args.interactive as boolean,
|
|
676
695
|
_: args,
|
|
677
696
|
});
|
package/src/common/constants.ts
CHANGED
|
@@ -6,6 +6,13 @@ export const piletJson = 'pilet.json';
|
|
|
6
6
|
export const filesOnceTar = 'files_once';
|
|
7
7
|
export const piralBaseRoot = 'piral-base/package.json';
|
|
8
8
|
export const defaultSchemaVersion = 'v2';
|
|
9
|
+
export const allName = 'all';
|
|
10
|
+
export const releaseName = 'release';
|
|
11
|
+
export const emulatorJson = 'emulator.json';
|
|
12
|
+
export const emulatorName = 'emulator';
|
|
13
|
+
export const emulatorPackageName = 'package';
|
|
14
|
+
export const emulatorSourcesName = 'sources';
|
|
15
|
+
export const emulatorWebsiteName = 'website';
|
|
9
16
|
export const frameworkLibs = ['piral' as const, 'piral-core' as const, 'piral-base' as const];
|
|
10
17
|
export const piletJsonSchemaUrl = 'https://docs.piral.io/schemas/pilet-v0.json';
|
|
11
18
|
export const piralJsonSchemaUrl = 'https://docs.piral.io/schemas/piral-v0.json';
|
package/src/common/emulator.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { join, resolve, relative, basename } from 'path';
|
|
2
2
|
import { findDependencyVersion, copyScaffoldingFiles, isValidDependency, flattenExternals } from './package';
|
|
3
3
|
import { createPiralStubIndexIfNotExists } from './template';
|
|
4
|
-
import { filesTar, filesOnceTar, packageJson, piralJson } from './constants';
|
|
4
|
+
import { filesTar, filesOnceTar, packageJson, piralJson, emulatorJson } from './constants';
|
|
5
5
|
import { cliVersion } from './info';
|
|
6
6
|
import { createNpmPackage } from './npm';
|
|
7
7
|
import { createPiralDeclaration } from './declaration';
|
|
@@ -238,7 +238,7 @@ export async function createEmulatorWebsite(
|
|
|
238
238
|
},
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
-
await writeJson(targetDir,
|
|
241
|
+
await writeJson(targetDir, emulatorJson, data, true);
|
|
242
242
|
|
|
243
243
|
// generate the associated index.d.ts
|
|
244
244
|
await createPiralDeclaration(sourceDir, piralPkg.app ?? `./src/index.html`, targetDir, ForceOverwrite.yes, logLevel);
|
package/src/common/http.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { log } from './log';
|
|
|
7
7
|
import { standardHeaders } from './info';
|
|
8
8
|
import { getTokenInteractively } from './interactive';
|
|
9
9
|
import { axios, FormData } from '../external';
|
|
10
|
-
import {
|
|
10
|
+
import { PublishScheme } from '../types';
|
|
11
11
|
|
|
12
12
|
function getMessage(body: string | { message?: string }) {
|
|
13
13
|
if (typeof body === 'string') {
|
|
@@ -67,7 +67,7 @@ export type FormDataObj = Record<string, string | number | boolean | [Buffer, st
|
|
|
67
67
|
|
|
68
68
|
export function postForm(
|
|
69
69
|
target: string,
|
|
70
|
-
scheme:
|
|
70
|
+
scheme: PublishScheme,
|
|
71
71
|
key: string,
|
|
72
72
|
formData: FormDataObj,
|
|
73
73
|
customHeaders: Record<string, string> = {},
|
|
@@ -192,7 +192,7 @@ export function postForm(
|
|
|
192
192
|
|
|
193
193
|
export function postFile(
|
|
194
194
|
target: string,
|
|
195
|
-
scheme:
|
|
195
|
+
scheme: PublishScheme,
|
|
196
196
|
key: string,
|
|
197
197
|
file: Buffer,
|
|
198
198
|
customFields: Record<string, string> = {},
|
package/src/common/index.ts
CHANGED
|
@@ -25,8 +25,11 @@ export * from './package';
|
|
|
25
25
|
export * from './parallel';
|
|
26
26
|
export * from './patcher';
|
|
27
27
|
export * from './patches';
|
|
28
|
+
export * from './pilet';
|
|
29
|
+
export * from './piral';
|
|
28
30
|
export * from './platform';
|
|
29
31
|
export * from './port';
|
|
32
|
+
export * from './release';
|
|
30
33
|
export * from './rules';
|
|
31
34
|
export * from './scaffold';
|
|
32
35
|
export * from './scripts';
|
|
@@ -3,7 +3,7 @@ import { openBrowserAt } from './browser';
|
|
|
3
3
|
import { standardHeaders } from './info';
|
|
4
4
|
import { logSuspend, logInfo } from './log';
|
|
5
5
|
import { axios, inquirer } from '../external';
|
|
6
|
-
import {
|
|
6
|
+
import { PublishScheme } from '../types';
|
|
7
7
|
|
|
8
8
|
export function promptSelect(message: string, values: Array<string>, defaultValue: string): Promise<string> {
|
|
9
9
|
const questions = [
|
|
@@ -30,7 +30,7 @@ export function promptConfirm(message: string, defaultValue: boolean): Promise<b
|
|
|
30
30
|
return inquirer.prompt(questions).then((answers: any) => answers.q);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
type TokenResult = Promise<{ mode:
|
|
33
|
+
type TokenResult = Promise<{ mode: PublishScheme; token: string }>;
|
|
34
34
|
|
|
35
35
|
const tokenRetrievers: Record<string, TokenResult> = {};
|
|
36
36
|
|