piral-cli 1.5.0-beta.6684 → 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/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/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/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/publish-pilet.ts +35 -62
- package/src/apps/publish-piral.ts +150 -80
- 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/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
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
2
|
+
import { runScript } from './scripts';
|
|
3
|
+
import { removeDirectory } from './io';
|
|
4
|
+
import { flattenExternals } from './package';
|
|
5
|
+
import { log, logDone, logInfo, progress } from './log';
|
|
6
|
+
import { createEmulatorSources, createEmulatorWebsite, packageEmulator } from './emulator';
|
|
7
|
+
import { emulatorName, emulatorPackageName, emulatorSourcesName, emulatorWebsiteName, releaseName } from './constants';
|
|
8
|
+
import { callPiralBuild } from '../bundler';
|
|
9
|
+
import { LogLevels, SharedDependency } from '../types';
|
|
10
|
+
|
|
11
|
+
async function runLifecycle(root: string, scripts: Record<string, string>, type: string) {
|
|
12
|
+
const script = scripts?.[type];
|
|
13
|
+
|
|
14
|
+
if (script) {
|
|
15
|
+
log('generalDebug_0003', `Running "${type}" ("${script}") ...`);
|
|
16
|
+
await runScript(script, root);
|
|
17
|
+
log('generalDebug_0003', `Finished running "${type}".`);
|
|
18
|
+
} else {
|
|
19
|
+
log('generalDebug_0003', `No script for "${type}" found ...`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface BaseBuildPiralOptions {
|
|
24
|
+
root: string;
|
|
25
|
+
targetDir: string;
|
|
26
|
+
logLevel: LogLevels;
|
|
27
|
+
bundlerName: string;
|
|
28
|
+
externals: Array<SharedDependency>;
|
|
29
|
+
ignored: Array<string>;
|
|
30
|
+
outFile: string;
|
|
31
|
+
entryFiles: string;
|
|
32
|
+
optimizeModules: boolean;
|
|
33
|
+
sourceMaps: boolean;
|
|
34
|
+
watch: boolean;
|
|
35
|
+
contentHash: boolean;
|
|
36
|
+
piralInstances: Array<string>;
|
|
37
|
+
scripts?: Record<string, string>;
|
|
38
|
+
hooks?: {
|
|
39
|
+
beforeBuild?(e: any): Promise<void>;
|
|
40
|
+
afterBuild?(e: any): Promise<void>;
|
|
41
|
+
beforeEmulator?(e: any): Promise<void>;
|
|
42
|
+
afterEmulator?(e: any): Promise<void>;
|
|
43
|
+
beforePackage?(e: any): Promise<void>;
|
|
44
|
+
afterPackage?(e: any): Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
_: Record<string, any>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface BuildEmulatorOptions extends BaseBuildPiralOptions {
|
|
50
|
+
emulatorType: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function triggerBuildEmulator({
|
|
54
|
+
root,
|
|
55
|
+
logLevel,
|
|
56
|
+
externals,
|
|
57
|
+
emulatorType,
|
|
58
|
+
bundlerName,
|
|
59
|
+
optimizeModules,
|
|
60
|
+
sourceMaps,
|
|
61
|
+
watch,
|
|
62
|
+
ignored,
|
|
63
|
+
contentHash,
|
|
64
|
+
targetDir,
|
|
65
|
+
outFile,
|
|
66
|
+
scripts,
|
|
67
|
+
entryFiles,
|
|
68
|
+
piralInstances,
|
|
69
|
+
hooks,
|
|
70
|
+
_,
|
|
71
|
+
}: BuildEmulatorOptions) {
|
|
72
|
+
progress('Starting emulator build ...');
|
|
73
|
+
|
|
74
|
+
const emulatorPublicUrl = '/';
|
|
75
|
+
const appDir = emulatorType !== emulatorWebsiteName ? join(targetDir, 'app') : targetDir;
|
|
76
|
+
|
|
77
|
+
// since we create this anyway let's just pretend we want to have it clean!
|
|
78
|
+
await removeDirectory(targetDir);
|
|
79
|
+
|
|
80
|
+
await hooks.beforeBuild?.({ root, publicUrl: emulatorPublicUrl, externals, entryFiles, targetDir, piralInstances });
|
|
81
|
+
|
|
82
|
+
logInfo(`Bundle ${emulatorName} ...`);
|
|
83
|
+
|
|
84
|
+
const {
|
|
85
|
+
dir: outDir,
|
|
86
|
+
name,
|
|
87
|
+
hash,
|
|
88
|
+
} = await callPiralBuild(
|
|
89
|
+
{
|
|
90
|
+
root,
|
|
91
|
+
piralInstances,
|
|
92
|
+
emulator: true,
|
|
93
|
+
standalone: false,
|
|
94
|
+
optimizeModules,
|
|
95
|
+
sourceMaps,
|
|
96
|
+
watch,
|
|
97
|
+
contentHash,
|
|
98
|
+
minify: false,
|
|
99
|
+
externals: flattenExternals(externals),
|
|
100
|
+
publicUrl: emulatorPublicUrl,
|
|
101
|
+
entryFiles,
|
|
102
|
+
logLevel,
|
|
103
|
+
ignored,
|
|
104
|
+
outDir: appDir,
|
|
105
|
+
outFile,
|
|
106
|
+
_,
|
|
107
|
+
},
|
|
108
|
+
bundlerName,
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
await hooks.afterBuild?.({
|
|
112
|
+
root,
|
|
113
|
+
publicUrl: emulatorPublicUrl,
|
|
114
|
+
externals,
|
|
115
|
+
entryFiles,
|
|
116
|
+
targetDir,
|
|
117
|
+
piralInstances,
|
|
118
|
+
hash,
|
|
119
|
+
outDir,
|
|
120
|
+
outFile: name,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
await runLifecycle(root, scripts, 'piral:postbuild');
|
|
124
|
+
await runLifecycle(root, scripts, `piral:postbuild-${emulatorName}`);
|
|
125
|
+
|
|
126
|
+
await hooks.beforeEmulator?.({ root, externals, targetDir, outDir });
|
|
127
|
+
|
|
128
|
+
let rootDir = root;
|
|
129
|
+
|
|
130
|
+
switch (emulatorType) {
|
|
131
|
+
case emulatorPackageName:
|
|
132
|
+
rootDir = await createEmulatorSources(root, externals, outDir, outFile, logLevel);
|
|
133
|
+
await hooks.beforePackage?.({ root, externals, targetDir, outDir, rootDir });
|
|
134
|
+
await packageEmulator(rootDir);
|
|
135
|
+
await hooks.afterPackage?.({ root, externals, targetDir, outDir, rootDir });
|
|
136
|
+
break;
|
|
137
|
+
case emulatorSourcesName:
|
|
138
|
+
rootDir = await createEmulatorSources(root, externals, outDir, outFile, logLevel);
|
|
139
|
+
logDone(`Emulator package sources available in "${rootDir}".`);
|
|
140
|
+
break;
|
|
141
|
+
case emulatorWebsiteName:
|
|
142
|
+
rootDir = await createEmulatorWebsite(root, externals, outDir, outFile, logLevel);
|
|
143
|
+
logDone(`Emulator website available in "${rootDir}".`);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
await hooks.afterEmulator?.({ root, externals, targetDir, outDir, rootDir });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface BuildShellOptions extends BaseBuildPiralOptions {
|
|
151
|
+
minify: boolean;
|
|
152
|
+
publicUrl: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export async function triggerBuildShell({
|
|
156
|
+
root,
|
|
157
|
+
targetDir,
|
|
158
|
+
bundlerName,
|
|
159
|
+
minify,
|
|
160
|
+
optimizeModules,
|
|
161
|
+
entryFiles,
|
|
162
|
+
piralInstances,
|
|
163
|
+
sourceMaps,
|
|
164
|
+
logLevel,
|
|
165
|
+
ignored,
|
|
166
|
+
watch,
|
|
167
|
+
outFile,
|
|
168
|
+
publicUrl,
|
|
169
|
+
contentHash,
|
|
170
|
+
externals,
|
|
171
|
+
hooks,
|
|
172
|
+
scripts,
|
|
173
|
+
_,
|
|
174
|
+
}: BuildShellOptions) {
|
|
175
|
+
progress('Starting release build ...');
|
|
176
|
+
|
|
177
|
+
// since we create this anyway let's just pretend we want to have it clean!
|
|
178
|
+
await removeDirectory(targetDir);
|
|
179
|
+
|
|
180
|
+
logInfo(`Bundle ${releaseName} ...`);
|
|
181
|
+
|
|
182
|
+
await hooks.beforeBuild?.({ root, publicUrl, externals, entryFiles, targetDir, piralInstances });
|
|
183
|
+
|
|
184
|
+
const {
|
|
185
|
+
dir: outDir,
|
|
186
|
+
name,
|
|
187
|
+
hash,
|
|
188
|
+
} = await callPiralBuild(
|
|
189
|
+
{
|
|
190
|
+
root,
|
|
191
|
+
piralInstances,
|
|
192
|
+
emulator: false,
|
|
193
|
+
standalone: false,
|
|
194
|
+
optimizeModules,
|
|
195
|
+
sourceMaps,
|
|
196
|
+
watch,
|
|
197
|
+
contentHash,
|
|
198
|
+
minify,
|
|
199
|
+
externals: flattenExternals(externals),
|
|
200
|
+
publicUrl,
|
|
201
|
+
outFile,
|
|
202
|
+
outDir: targetDir,
|
|
203
|
+
entryFiles,
|
|
204
|
+
logLevel,
|
|
205
|
+
ignored,
|
|
206
|
+
_,
|
|
207
|
+
},
|
|
208
|
+
bundlerName,
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
await hooks.afterBuild?.({
|
|
212
|
+
root,
|
|
213
|
+
publicUrl,
|
|
214
|
+
externals,
|
|
215
|
+
entryFiles,
|
|
216
|
+
targetDir,
|
|
217
|
+
piralInstances,
|
|
218
|
+
outDir,
|
|
219
|
+
outFile: name,
|
|
220
|
+
hash,
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
await runLifecycle(root, scripts, 'piral:postbuild');
|
|
224
|
+
await runLifecycle(root, scripts, `piral:postbuild-${releaseName}`);
|
|
225
|
+
|
|
226
|
+
logDone(`Files for publication available in "${outDir}".`);
|
|
227
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { basename, dirname, relative, resolve } from 'path';
|
|
2
|
+
import { fail, log } from './log';
|
|
3
|
+
import { publishNpmPackage } from './npm';
|
|
4
|
+
import { FormDataObj, postForm } from './http';
|
|
5
|
+
import { checkExists, matchFiles, readBinary } from './io';
|
|
6
|
+
import { PublishScheme } from '../types';
|
|
7
|
+
|
|
8
|
+
export async function publishPackageEmulator(
|
|
9
|
+
baseDir: string,
|
|
10
|
+
source: string,
|
|
11
|
+
args: Record<string, string> = {},
|
|
12
|
+
interactive = false,
|
|
13
|
+
) {
|
|
14
|
+
const type = 'emulator';
|
|
15
|
+
const directory = resolve(baseDir, source, type);
|
|
16
|
+
const exists = await checkExists(directory);
|
|
17
|
+
|
|
18
|
+
if (!exists) {
|
|
19
|
+
fail('publishDirectoryMissing_0110', directory);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const files = await matchFiles(directory, '*.tgz');
|
|
23
|
+
log('generalDebug_0003', `Found ${files.length} in "${directory}": ${files.join(', ')}`);
|
|
24
|
+
|
|
25
|
+
if (files.length !== 1) {
|
|
26
|
+
fail('publishEmulatorFilesUnexpected_0111', directory);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const [file] = files;
|
|
30
|
+
const flags = Object.keys(args).reduce((p, c) => {
|
|
31
|
+
p.push(`--${c}`, args[c]);
|
|
32
|
+
return p;
|
|
33
|
+
}, [] as Array<string>);
|
|
34
|
+
|
|
35
|
+
await publishNpmPackage(directory, file, flags, interactive);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function publishWebsiteEmulator(
|
|
39
|
+
version: string,
|
|
40
|
+
url: string,
|
|
41
|
+
apiKey: string,
|
|
42
|
+
mode: PublishScheme,
|
|
43
|
+
directory: string,
|
|
44
|
+
files: Array<string>,
|
|
45
|
+
interactive: boolean,
|
|
46
|
+
headers?: Record<string, string>,
|
|
47
|
+
ca?: Buffer,
|
|
48
|
+
) {
|
|
49
|
+
const data: FormDataObj = {
|
|
50
|
+
version,
|
|
51
|
+
type: 'custom',
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
for (const file of files) {
|
|
55
|
+
const relPath = relative(directory, file);
|
|
56
|
+
const fileName = basename(file);
|
|
57
|
+
const content = await readBinary(dirname(file), fileName);
|
|
58
|
+
data[relPath] = [content, fileName];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return await postForm(url, mode, apiKey, data, headers, ca, interactive);
|
|
62
|
+
}
|
package/src/helpers.ts
CHANGED
|
@@ -7,12 +7,12 @@ import type {
|
|
|
7
7
|
PiletPublishSource,
|
|
8
8
|
PiralBuildType,
|
|
9
9
|
PiletBuildType,
|
|
10
|
-
|
|
10
|
+
PublishScheme,
|
|
11
11
|
SourceLanguage,
|
|
12
12
|
} from './types';
|
|
13
13
|
|
|
14
14
|
export const schemaKeys: Array<PiletSchemaVersion> = ['v0', 'v1', 'v2', 'v3', 'mf', 'none'];
|
|
15
|
-
export const publishModeKeys: Array<
|
|
15
|
+
export const publishModeKeys: Array<PublishScheme> = ['none', 'basic', 'bearer', 'digest'];
|
|
16
16
|
export const fromKeys: Array<PiletPublishSource> = ['local', 'remote', 'npm'];
|
|
17
17
|
export const piralBuildTypeKeys: Array<PiralBuildType> = [
|
|
18
18
|
'all',
|
package/src/messages.ts
CHANGED
|
@@ -2585,6 +2585,28 @@ export function requiredEmulatorAssetDownloadSkipped_0123(url: string): QuickMes
|
|
|
2585
2585
|
return [LogLevels.warning, '0123', `Could not download asset file at "${url}".`];
|
|
2586
2586
|
}
|
|
2587
2587
|
|
|
2588
|
+
/**
|
|
2589
|
+
* @kind Error
|
|
2590
|
+
*
|
|
2591
|
+
* @summary
|
|
2592
|
+
* The emulator.json and associated files could not be found in the source directory.
|
|
2593
|
+
*
|
|
2594
|
+
* @abstract
|
|
2595
|
+
* Only an emulator website can be published using `piral publish`. Other artifacts such as
|
|
2596
|
+
* standard release artifacts or the package emulator (tgz) need to be published using other
|
|
2597
|
+
* mechanisms such as `npm publish`.
|
|
2598
|
+
*
|
|
2599
|
+
* If no emulator website exists you can either build one using the `--fresh` flag with
|
|
2600
|
+
* `piral publish` (i.e., `piral publish --fresh`) or preparing the build using `piral build`
|
|
2601
|
+
* with the `--type emulator-website` flag.
|
|
2602
|
+
*
|
|
2603
|
+
* @see
|
|
2604
|
+
* - [Emulator](https://docs.piral.io/concepts/T01-emulator)
|
|
2605
|
+
*/
|
|
2606
|
+
export function missingEmulatorWebsite_0130(path: string): QuickMessage {
|
|
2607
|
+
return [LogLevels.error, '0130', `Could not find the files for an emulator website at "${path}".`];
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2588
2610
|
/**
|
|
2589
2611
|
* @kind Warning
|
|
2590
2612
|
*
|
package/src/types/public.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Argv, Arguments } from 'yargs';
|
|
2
|
-
import { RuleRunner, PiletRuleContext, PiralRuleContext, LogLevels, SharedDependency
|
|
2
|
+
import { RuleRunner, PiletRuleContext, PiralRuleContext, LogLevels, SharedDependency } from './common';
|
|
3
3
|
|
|
4
4
|
export interface ToolCommandRunner<U = {}> {
|
|
5
5
|
(args: Arguments<U>): void | Promise<void>;
|
|
@@ -44,7 +44,6 @@ export interface CliPluginApi {
|
|
|
44
44
|
withPiletRule(ruleName: string, runner: RuleRunner<PiletRuleContext>): CliPluginApi;
|
|
45
45
|
withPatcher(packageName: string, patch: PackagePatcher): CliPluginApi;
|
|
46
46
|
withBundler(bundlerName: string, bundler: BundlerDefinition): CliPluginApi;
|
|
47
|
-
withReleaseProvider(providerName: string, provider: ReleaseProvider): CliPluginApi;
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
export interface CliPlugin {
|
|
@@ -242,7 +241,7 @@ export type AuthConfig = HeaderAuthConfig | HttpAuthConfig;
|
|
|
242
241
|
|
|
243
242
|
export type SourceLanguage = 'js' | 'ts';
|
|
244
243
|
|
|
245
|
-
export type
|
|
244
|
+
export type PublishScheme = 'none' | 'digest' | 'bearer' | 'basic';
|
|
246
245
|
|
|
247
246
|
export type PiletPublishSource = 'local' | 'npm' | 'remote';
|
|
248
247
|
|
package/lib/release.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ReleaseProvider } from './types';
|
|
2
|
-
export interface QualifiedReleaseProvider {
|
|
3
|
-
name: string;
|
|
4
|
-
action: ReleaseProvider;
|
|
5
|
-
}
|
|
6
|
-
export declare function setReleaseProvider(provider: QualifiedReleaseProvider): void;
|
|
7
|
-
export declare function publishArtifacts(providerName: string, directory: string, files: Array<string>, args: Record<string, string>, interactive: boolean): Promise<void>;
|
package/lib/release.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.publishArtifacts = exports.setReleaseProvider = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const common_1 = require("./common");
|
|
6
|
-
const helpers_1 = require("./helpers");
|
|
7
|
-
async function getVersion(directory) {
|
|
8
|
-
const data = await (0, common_1.findFile)(directory, 'package.json');
|
|
9
|
-
if (!data) {
|
|
10
|
-
(0, common_1.fail)('packageJsonNotFound_0020');
|
|
11
|
-
}
|
|
12
|
-
const { version } = require(data);
|
|
13
|
-
return version;
|
|
14
|
-
}
|
|
15
|
-
const providers = {
|
|
16
|
-
none() {
|
|
17
|
-
return Promise.resolve();
|
|
18
|
-
},
|
|
19
|
-
async xcopy(_, files, args) {
|
|
20
|
-
const { target } = args;
|
|
21
|
-
if (!target) {
|
|
22
|
-
(0, common_1.fail)('publishXcopyMissingTarget_0112');
|
|
23
|
-
}
|
|
24
|
-
await Promise.all(files.map(async (file) => (0, common_1.copy)(file, (0, path_1.resolve)(target, (0, path_1.basename)(file)))));
|
|
25
|
-
},
|
|
26
|
-
async feed(directory, files, args, interactive) {
|
|
27
|
-
const { url, apiKey, scheme = 'basic', version = await getVersion(directory) } = args;
|
|
28
|
-
if (!url) {
|
|
29
|
-
(0, common_1.fail)('publishFeedMissingUrl_0115');
|
|
30
|
-
}
|
|
31
|
-
if (!version) {
|
|
32
|
-
(0, common_1.fail)('publishFeedMissingVersion_0116');
|
|
33
|
-
}
|
|
34
|
-
const data = {
|
|
35
|
-
version,
|
|
36
|
-
type: 'custom',
|
|
37
|
-
};
|
|
38
|
-
for (const file of files) {
|
|
39
|
-
const relPath = (0, path_1.relative)(directory, file);
|
|
40
|
-
const fileName = (0, path_1.basename)(file);
|
|
41
|
-
const content = await (0, common_1.readBinary)((0, path_1.dirname)(file), fileName);
|
|
42
|
-
data[relPath] = [content, fileName];
|
|
43
|
-
}
|
|
44
|
-
await (0, common_1.postForm)(url, scheme, apiKey, data, {}, undefined, interactive);
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
function findReleaseProvider(providerName) {
|
|
48
|
-
const provider = providers[providerName];
|
|
49
|
-
if (typeof provider !== 'function') {
|
|
50
|
-
(0, common_1.fail)('publishProviderMissing_0113', providerName, helpers_1.availableReleaseProviders);
|
|
51
|
-
}
|
|
52
|
-
return provider;
|
|
53
|
-
}
|
|
54
|
-
helpers_1.availableReleaseProviders.push(...Object.keys(providers));
|
|
55
|
-
function setReleaseProvider(provider) {
|
|
56
|
-
providers[provider.name] = provider.action;
|
|
57
|
-
if (!helpers_1.availableReleaseProviders.includes(provider.name)) {
|
|
58
|
-
helpers_1.availableReleaseProviders.push(provider.name);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.setReleaseProvider = setReleaseProvider;
|
|
62
|
-
function publishArtifacts(providerName, directory, files, args, interactive) {
|
|
63
|
-
const runRelease = findReleaseProvider(providerName);
|
|
64
|
-
return runRelease(directory, files, args, interactive);
|
|
65
|
-
}
|
|
66
|
-
exports.publishArtifacts = publishArtifacts;
|
|
67
|
-
//# sourceMappingURL=release.js.map
|
package/lib/release.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release.js","sourceRoot":"","sources":["../src/release.ts"],"names":[],"mappings":";;;AAAA,+BAA4D;AAC5D,qCAAmF;AACnF,uCAAsD;AAGtD,KAAK,UAAU,UAAU,CAAC,SAAiB;IACzC,MAAM,IAAI,GAAG,MAAM,IAAA,iBAAQ,EAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAEvD,IAAI,CAAC,IAAI,EAAE;QACT,IAAA,aAAI,EAAC,0BAA0B,CAAC,CAAC;KAClC;IAED,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,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
|
2
|
-
import { copy, fail, findFile, FormDataObj, postForm, readBinary } from './common';
|
|
3
|
-
import { availableReleaseProviders } from './helpers';
|
|
4
|
-
import { ReleaseProvider } from './types';
|
|
5
|
-
|
|
6
|
-
async function getVersion(directory: string) {
|
|
7
|
-
const data = await findFile(directory, 'package.json');
|
|
8
|
-
|
|
9
|
-
if (!data) {
|
|
10
|
-
fail('packageJsonNotFound_0020');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const { version } = require(data);
|
|
14
|
-
return version;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface QualifiedReleaseProvider {
|
|
18
|
-
name: string;
|
|
19
|
-
action: ReleaseProvider;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const providers: Record<string, ReleaseProvider> = {
|
|
23
|
-
none() {
|
|
24
|
-
return Promise.resolve();
|
|
25
|
-
},
|
|
26
|
-
async xcopy(_, files, args) {
|
|
27
|
-
const { target } = args;
|
|
28
|
-
|
|
29
|
-
if (!target) {
|
|
30
|
-
fail('publishXcopyMissingTarget_0112');
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
await Promise.all(files.map(async (file) => copy(file, resolve(target, basename(file)))));
|
|
34
|
-
},
|
|
35
|
-
async feed(directory, files, args, interactive) {
|
|
36
|
-
const { url, apiKey, scheme = 'basic', version = await getVersion(directory) } = args;
|
|
37
|
-
|
|
38
|
-
if (!url) {
|
|
39
|
-
fail('publishFeedMissingUrl_0115');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (!version) {
|
|
43
|
-
fail('publishFeedMissingVersion_0116');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const data: FormDataObj = {
|
|
47
|
-
version,
|
|
48
|
-
type: 'custom',
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
for (const file of files) {
|
|
52
|
-
const relPath = relative(directory, file);
|
|
53
|
-
const fileName = basename(file);
|
|
54
|
-
const content = await readBinary(dirname(file), fileName);
|
|
55
|
-
data[relPath] = [content, fileName];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
await postForm(url, scheme as any, apiKey, data, {}, undefined, interactive);
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
function findReleaseProvider(providerName: string) {
|
|
63
|
-
const provider = providers[providerName];
|
|
64
|
-
|
|
65
|
-
if (typeof provider !== 'function') {
|
|
66
|
-
fail('publishProviderMissing_0113', providerName, availableReleaseProviders);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return provider;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
availableReleaseProviders.push(...Object.keys(providers));
|
|
73
|
-
|
|
74
|
-
export function setReleaseProvider(provider: QualifiedReleaseProvider) {
|
|
75
|
-
providers[provider.name] = provider.action;
|
|
76
|
-
|
|
77
|
-
if (!availableReleaseProviders.includes(provider.name)) {
|
|
78
|
-
availableReleaseProviders.push(provider.name);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function publishArtifacts(
|
|
83
|
-
providerName: string,
|
|
84
|
-
directory: string,
|
|
85
|
-
files: Array<string>,
|
|
86
|
-
args: Record<string, string>,
|
|
87
|
-
interactive: boolean,
|
|
88
|
-
) {
|
|
89
|
-
const runRelease = findReleaseProvider(providerName);
|
|
90
|
-
return runRelease(directory, files, args, interactive);
|
|
91
|
-
}
|