@journeyapps/cloudcode-build-legacy 0.0.1 → 1.12.0-alpha.1
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/dist/BuildParameters.d.ts +2 -1
- package/dist/build.d.ts +5 -2
- package/dist/build.js +12 -31
- package/dist/build.js.map +1 -1
- package/dist/cli.js +5 -5
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +1 -5
- package/dist/config.js +2 -10
- package/dist/config.js.map +1 -1
- package/dist/index.js +9 -10
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/dist/cli-errors.d.ts +0 -8
- package/dist/cli-errors.js +0 -21
- package/dist/cli-errors.js.map +0 -1
- package/dist/entry.d.ts +0 -1
- package/dist/entry.js +0 -34
- package/dist/entry.js.map +0 -1
- package/dist/unzip.d.ts +0 -1
- package/dist/unzip.js +0 -179
- package/dist/unzip.js.map +0 -1
- package/dist/upload.d.ts +0 -1
- package/dist/upload.js +0 -23
- package/dist/upload.js.map +0 -1
package/dist/build.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @param src - path to the task. Must contain a cloudcode folder.
|
|
3
3
|
* @param dest - destination folder. Will contain an `app/cloudcode` folder after building.
|
|
4
|
-
* @param
|
|
4
|
+
* @param zipPath - path to use for creating a zip of dest.
|
|
5
5
|
* @param config - task config, written to config.json.
|
|
6
|
+
* @param options - build options.
|
|
6
7
|
*/
|
|
7
|
-
export declare function build(src: string, dest: string, zipPath: string
|
|
8
|
+
export declare function build(src: string, dest: string, zipPath: string, config: any, options: {
|
|
9
|
+
yarnHome: string;
|
|
10
|
+
}): Promise<string>;
|
package/dist/build.js
CHANGED
|
@@ -10,7 +10,6 @@ const glob = require("glob-promise");
|
|
|
10
10
|
const cloudcodeBuild = require("@journeyapps/cloudcode-build");
|
|
11
11
|
const yarn_1 = require("./yarn");
|
|
12
12
|
const error_1 = require("./error");
|
|
13
|
-
const { YARN_HOME } = require('./config');
|
|
14
13
|
const debug = require('debug')('build');
|
|
15
14
|
// Babel config for tasks that don't have a defined "build" step.
|
|
16
15
|
const BABEL_PLUGINS = [
|
|
@@ -107,13 +106,13 @@ async function zip(src, dest) {
|
|
|
107
106
|
/**
|
|
108
107
|
* @param src - path to the task. Must contain a cloudcode folder.
|
|
109
108
|
* @param dest - destination folder. Will contain an `app/cloudcode` folder after building.
|
|
110
|
-
* @param
|
|
109
|
+
* @param zipPath - path to use for creating a zip of dest.
|
|
111
110
|
* @param config - task config, written to config.json.
|
|
111
|
+
* @param options - build options.
|
|
112
112
|
*/
|
|
113
|
-
async function build(src, dest, zipPath, config) {
|
|
113
|
+
async function build(src, dest, zipPath, config, options) {
|
|
114
114
|
const taskName = config.task;
|
|
115
|
-
|
|
116
|
-
const runInstallScripts = config.runInstallScripts;
|
|
115
|
+
const yarnHome = options.yarnHome;
|
|
117
116
|
await jetpack.dir(dest, { empty: true });
|
|
118
117
|
debug('copy app');
|
|
119
118
|
const taskSrc = path.join(src, 'cloudcode', taskName);
|
|
@@ -140,7 +139,7 @@ async function build(src, dest, zipPath, config) {
|
|
|
140
139
|
await transformFiles(src, 'cloudcode/' + taskName, taskPath);
|
|
141
140
|
await transformFiles(src, path.join('cloudcode', 'shared'), taskSharedPath);
|
|
142
141
|
}
|
|
143
|
-
else if (!
|
|
142
|
+
else if (!isCloudCodeBuild) {
|
|
144
143
|
throw new error_1.BuildError(`Custom build scripts not allowed. Use \`"build": "cloudcode-build"\` in package.json.`, {
|
|
145
144
|
error: 'CLOUDCODE/BUILD/BUILD_FAILED'
|
|
146
145
|
});
|
|
@@ -149,7 +148,7 @@ async function build(src, dest, zipPath, config) {
|
|
|
149
148
|
if (needsYarn && !fs.existsSync(yarnLock)) {
|
|
150
149
|
throw new Error('yarn.lock required to install dependencies');
|
|
151
150
|
}
|
|
152
|
-
const cacheOptions = ['--cache-folder', path.join(
|
|
151
|
+
const cacheOptions = ['--cache-folder', path.join(yarnHome, 'yarn-cache')];
|
|
153
152
|
let args = [
|
|
154
153
|
'install',
|
|
155
154
|
// Yarn should auto-detect that we're not in an interactive shell, but we add this to make sure.
|
|
@@ -161,23 +160,10 @@ async function build(src, dest, zipPath, config) {
|
|
|
161
160
|
// Specify cache path
|
|
162
161
|
...cacheOptions
|
|
163
162
|
];
|
|
164
|
-
if (!runInstallScripts) {
|
|
165
|
-
// runInstallScripts is behind a hidden feature flag,
|
|
166
|
-
// Don't run lifecycle scripts when installing, which could be a security issue, unless it's
|
|
167
|
-
// authorized by the feature flag.
|
|
168
|
-
//
|
|
169
|
-
// The security issue is that this Lambda process may be re-used when rebuilding the next app,
|
|
170
|
-
// and lifecycle scripts could theoretically spawn a long-running process that can then read
|
|
171
|
-
// the source of the next app.
|
|
172
|
-
//
|
|
173
|
-
// Disabling scripts prevents certain packages from being installed correctly, especially packages using
|
|
174
|
-
// native extensions, or downloading external resources.
|
|
175
|
-
args.push('--ignore-scripts');
|
|
176
|
-
}
|
|
177
163
|
let env = {
|
|
178
164
|
// Yarn is hardcoded to store configuration in the user's home dir.
|
|
179
|
-
// Since our home dir
|
|
180
|
-
HOME:
|
|
165
|
+
// Since our home dir might be read-only, we override it for yarn.
|
|
166
|
+
HOME: yarnHome
|
|
181
167
|
};
|
|
182
168
|
try {
|
|
183
169
|
if (needsYarn && hasBuild) {
|
|
@@ -198,7 +184,7 @@ async function build(src, dest, zipPath, config) {
|
|
|
198
184
|
// For security purposes, use the bundled version, not whatever the developer specified.
|
|
199
185
|
await cloudcodeBuild.buildTask(taskPath);
|
|
200
186
|
}
|
|
201
|
-
else if (hasBuild
|
|
187
|
+
else if (hasBuild) {
|
|
202
188
|
// Custom build script.
|
|
203
189
|
await (0, yarn_1.runScript)(taskPath, ['run', '--quiet', 'build'], { env });
|
|
204
190
|
}
|
|
@@ -258,14 +244,9 @@ async function build(src, dest, zipPath, config) {
|
|
|
258
244
|
};
|
|
259
245
|
await jetpack.writeAsync(dest + '/config.json', JSON.stringify(savedConfig));
|
|
260
246
|
await createEntry(dest, destTaskPath);
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return zipPath;
|
|
265
|
-
}
|
|
266
|
-
else {
|
|
267
|
-
return dest;
|
|
268
|
-
}
|
|
247
|
+
debug('zip');
|
|
248
|
+
await zip(dest, zipPath);
|
|
249
|
+
return zipPath;
|
|
269
250
|
}
|
|
270
251
|
exports.build = build;
|
|
271
252
|
//# sourceMappingURL=build.js.map
|
package/dist/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,sCAAsC;AACtC,qCAAqC;AACrC,yBAAyB;AACzB,6BAA6B;AAC7B,qCAAqC;AACrC,+DAA+D;AAE/D,iCAA4C;AAC5C,mCAAqC;AAErC,MAAM,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,sCAAsC;AACtC,qCAAqC;AACrC,yBAAyB;AACzB,6BAA6B;AAC7B,qCAAqC;AACrC,+DAA+D;AAE/D,iCAA4C;AAC5C,mCAAqC;AAErC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AAExC,iEAAiE;AACjE,MAAM,aAAa,GAAG;IACpB,oDAAoD;IACpD,0CAA0C;CAC3C,CAAC;AAEF,MAAM,aAAa,GAA2B;IAC5C,OAAO,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/D,UAAU,EAAE,QAAQ;IACpB,aAAa,EAAE,KAAK;CACrB,CAAC;AAEF,KAAK,UAAU,aAAa,CAAC,IAAY;IACvC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,KAAK,CAA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AAM,OAAO,CAAC,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;SAC/C;KACF;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,IAAI,kBAAU,CAAC,GAAG,CAAC,OAAO,EAAE;YAChC,KAAK,EAAE,sCAAsC;YAC7C,KAAK,EAAE,GAAG;SACX,CAAC,CAAC;KACJ;IAED,MAAM,WAAW,GAAG;QAClB,gFAAgF;QAChF,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,GAAG,EAAE,MAAM,CAAC,GAAG;KAChB,CAAC;IAEF,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,cAAc,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;IAE7E,MAAM,WAAW,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAEtC,KAAK,CAAC,KAAK,CAAC,CAAC;IACb,MAAM,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzB,OAAO,OAAO,CAAC;AACjB,CAAC;AAzJD,sBAyJC"}
|
package/dist/cli.js
CHANGED
|
@@ -9,9 +9,9 @@ yargs
|
|
|
9
9
|
return (yargs
|
|
10
10
|
.option('src', { string: true, demandOption: true })
|
|
11
11
|
.option('out', { string: true, demandOption: true })
|
|
12
|
-
.option('zip', { string: true })
|
|
12
|
+
.option('zip', { string: true, demandOption: true })
|
|
13
13
|
.option('task', { string: true, demandOption: true })
|
|
14
|
-
.option('
|
|
14
|
+
.option('yarnHome', { string: true })
|
|
15
15
|
// TODO: investigate yargs.config() for reading task config blob from a file. But how to ensure required args?
|
|
16
16
|
.option('appId', { string: true, demandOption: true, describe: "CloudCode's reference id" })
|
|
17
17
|
.option('env', { string: true, demandOption: true })
|
|
@@ -27,9 +27,9 @@ yargs
|
|
|
27
27
|
env: argv.env,
|
|
28
28
|
task: argv.task,
|
|
29
29
|
appInstanceIds: [argv.backendId],
|
|
30
|
-
backendUrl: argv.backendUrl
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
backendUrl: argv.backendUrl
|
|
31
|
+
},
|
|
32
|
+
yarnHome: argv.yarnHome
|
|
33
33
|
});
|
|
34
34
|
}))
|
|
35
35
|
.option('verbose', {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,+BAA+B;AAE/B,mCAA0C;AAE1C,KAAK;KACF,OAAO,CACN,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,uCAAuC;AACxD,YAAY,EACZ,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CACL,KAAK;SACF,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;AAEA,+BAA+B;AAE/B,mCAA0C;AAE1C,KAAK;KACF,OAAO,CACN,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,uCAAuC;AACxD,YAAY,EACZ,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CACL,KAAK;SACF,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;SACnD,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM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AI,EAA8B;IAChD,OAAO,KAAK,EAAE,IAAO,EAAE,EAAE;QACvB,IAAI;YACF,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC;SAChB;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACjB;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
declare const TMP_PATH = "/tmp/cloudcode-build";
|
|
2
|
-
declare const WORKING_PATH: string;
|
|
3
|
-
declare const APP_PATH: string;
|
|
4
|
-
declare const OUTPUT_PATH: string;
|
|
5
|
-
declare const ZIP_PATH: string;
|
|
6
2
|
declare const YARN_HOME: string;
|
|
7
|
-
export { TMP_PATH,
|
|
3
|
+
export { TMP_PATH, YARN_HOME };
|
package/dist/config.js
CHANGED
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.YARN_HOME = exports.
|
|
4
|
-
const TMP_PATH = '/tmp/cloudcode-build';
|
|
3
|
+
exports.YARN_HOME = exports.TMP_PATH = void 0;
|
|
4
|
+
const TMP_PATH = '/tmp/cloudcode-build';
|
|
5
5
|
exports.TMP_PATH = TMP_PATH;
|
|
6
|
-
const WORKING_PATH = TMP_PATH + '/extract';
|
|
7
|
-
exports.WORKING_PATH = WORKING_PATH;
|
|
8
|
-
const APP_PATH = WORKING_PATH + '/app';
|
|
9
|
-
exports.APP_PATH = APP_PATH;
|
|
10
|
-
const OUTPUT_PATH = TMP_PATH + '/dist';
|
|
11
|
-
exports.OUTPUT_PATH = OUTPUT_PATH;
|
|
12
|
-
const ZIP_PATH = TMP_PATH + '/build.zip';
|
|
13
|
-
exports.ZIP_PATH = ZIP_PATH;
|
|
14
6
|
const YARN_HOME = TMP_PATH + '/yarn';
|
|
15
7
|
exports.YARN_HOME = YARN_HOME;
|
|
16
8
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG,sBAAsB,CAAC
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAA,MAAM,QAAQ,GAAG,sBAAsB,CAAC;AAG/B,4BAAQ;AAFjB,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;AAElB,8BAAS"}
|
package/dist/index.js
CHANGED
|
@@ -5,18 +5,18 @@ const jetpack = require("fs-jetpack");
|
|
|
5
5
|
const build_1 = require("./build");
|
|
6
6
|
const error_1 = require("./error");
|
|
7
7
|
const debug = require('debug')('build');
|
|
8
|
-
const { TMP_PATH,
|
|
8
|
+
const { TMP_PATH, YARN_HOME } = require('./config');
|
|
9
9
|
async function handle(event) {
|
|
10
|
-
var _a
|
|
10
|
+
var _a;
|
|
11
11
|
try {
|
|
12
|
-
await jetpack.dir(TMP_PATH, { empty: true });
|
|
13
|
-
await jetpack.dir(
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
// await jetpack.dir(TMP_PATH, { empty: true });
|
|
13
|
+
await jetpack.dir(TMP_PATH, {});
|
|
14
|
+
const appPath = event.appPath;
|
|
15
|
+
const outPath = event.outPath;
|
|
16
|
+
const zipPath = event.zipPath;
|
|
17
|
+
const yarnHome = (_a = event.yarnHome) !== null && _a !== void 0 ? _a : YARN_HOME;
|
|
18
18
|
debug('building...');
|
|
19
|
-
var zipFile = await (0, build_1.build)(
|
|
19
|
+
var zipFile = await (0, build_1.build)(appPath, outPath, zipPath, event.taskConfig, { yarnHome });
|
|
20
20
|
debug('built', outPath, zipFile);
|
|
21
21
|
debug('done.');
|
|
22
22
|
return 'done!';
|
|
@@ -24,7 +24,6 @@ async function handle(event) {
|
|
|
24
24
|
catch (error) {
|
|
25
25
|
const wrappedError = error_1.BuildError.fromError(error);
|
|
26
26
|
console.error(wrappedError); // Includes error.stack
|
|
27
|
-
// return wrappedError;
|
|
28
27
|
throw wrappedError;
|
|
29
28
|
}
|
|
30
29
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,mCAAgC;AAChC,mCAAqC;AAGrC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AAExC,MAAM,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,mCAAgC;AAChC,mCAAqC;AAGrC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC;AAExC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAE7C,KAAK,UAAU,MAAM,CAAC,KAAsB;;IACjD,IAAI;QACF,gDAAgD;QAChD,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAEhC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;QAC9B,MAAM,QAAQ,GAAG,MAAA,KAAK,CAAC,QAAQ,mCAAI,SAAS,CAAC;QAE7C,KAAK,CAAC,aAAa,CAAC,CAAC;QACrB,IAAI,OAAO,GAAG,MAAM,IAAA,aAAK,EAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QACrF,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,OAAO,OAAO,CAAC;KAChB;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,YAAY,GAAG,kBAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACjD,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,uBAAuB;QACpD,MAAM,YAAY,CAAC;KACpB;AACH,CAAC;AApBD,wBAoBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeyapps/cloudcode-build-legacy",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.12.0-alpha.1",
|
|
4
4
|
"description": "Port of JourneyApps CloudCode's legacy build tooling.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"lodash": "^4.17.2",
|
|
29
29
|
"mkdirp": "^0.5.1",
|
|
30
30
|
"source-map-support": "^0.4.2",
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"yargs": "17.7.1",
|
|
32
|
+
"yarn": "^1.7.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "14.18.36",
|
package/dist/cli-errors.d.ts
DELETED
package/dist/cli-errors.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProcessError = void 0;
|
|
4
|
-
class ProcessError extends Error {
|
|
5
|
-
constructor(result) {
|
|
6
|
-
super(constructMessage(result));
|
|
7
|
-
this.result = result;
|
|
8
|
-
if (result.error) {
|
|
9
|
-
this.cause = result.error;
|
|
10
|
-
}
|
|
11
|
-
this.status = result.status || 1;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
exports.ProcessError = ProcessError;
|
|
15
|
-
function constructMessage(result) {
|
|
16
|
-
if (result.error) {
|
|
17
|
-
return result.error.message;
|
|
18
|
-
}
|
|
19
|
-
return `${result.stdout}${result.stderr}`.trim();
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=cli-errors.js.map
|
package/dist/cli-errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli-errors.js","sourceRoot":"","sources":["../src/cli-errors.ts"],"names":[],"mappings":";;;AAEA,MAAa,YAAa,SAAQ,KAAK;IAIrC,YAAmB,MAAgC;QACjD,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;QADf,WAAM,GAAN,MAAM,CAA0B;QAGjD,IAAI,MAAM,CAAC,KAAK,EAAE;YAChB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;SAC3B;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAZD,oCAYC;AAED,SAAS,gBAAgB,CAAC,MAAgC;IACxD,IAAI,MAAM,CAAC,KAAK,EAAE;QAChB,OAAO,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC;KAC7B;IACD,OAAO,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC;AACnD,CAAC"}
|
package/dist/entry.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/entry.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require('source-map-support').install();
|
|
4
|
-
const index_1 = require("./index");
|
|
5
|
-
// For AWS Lambda
|
|
6
|
-
exports.handler = async function (event, context) {
|
|
7
|
-
console.log('processing event: %j', event);
|
|
8
|
-
return await (0, index_1.handle)(event, context);
|
|
9
|
-
};
|
|
10
|
-
// For CLI usage
|
|
11
|
-
exports.run = function (event) {
|
|
12
|
-
var context = { cli: true };
|
|
13
|
-
(0, index_1.handle)(event, context).then(function (result) {
|
|
14
|
-
console.log('Result: ', result);
|
|
15
|
-
}, function (error) {
|
|
16
|
-
if (error.stack) {
|
|
17
|
-
console.error(error.stack);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
console.error('Error:', error);
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
if (module == require.main) {
|
|
25
|
-
var event;
|
|
26
|
-
if (process.argv.length > 2) {
|
|
27
|
-
event = JSON.parse(process.argv[2]);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
event = {};
|
|
31
|
-
}
|
|
32
|
-
exports.run(event);
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=entry.js.map
|
package/dist/entry.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"entry.js","sourceRoot":"","sources":["../src/entry.ts"],"names":[],"mappings":";;AAAA,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAC;AACxC,mCAAwC;AAExC,iBAAiB;AACjB,OAAO,CAAC,OAAO,GAAG,KAAK,WAAW,KAAK,EAAE,OAAO;IAC9C,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;IAC3C,OAAO,MAAM,IAAA,cAAG,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC,CAAC;AAEF,gBAAgB;AAChB,OAAO,CAAC,GAAG,GAAG,UAAU,KAAK;IAC3B,IAAI,OAAO,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IAC5B,IAAA,cAAG,EAAC,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,CACtB,UAAU,MAAM;QACd,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC,EACD,UAAU,KAAK;QACb,IAAI,KAAK,CAAC,KAAK,EAAE;YACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SAC5B;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;SAChC;IACH,CAAC,CACF,CAAC;AACJ,CAAC,CAAC;AAEF,IAAI,MAAM,IAAI,OAAO,CAAC,IAAI,EAAE;IAC1B,IAAI,KAAK,CAAC;IACV,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;KACrC;SAAM;QACL,KAAK,GAAG,EAAE,CAAC;KACZ;IACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;CACpB"}
|
package/dist/unzip.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function downloadAndExtract(url: string, destination: string): Promise<string>;
|
package/dist/unzip.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Adapted from https://github.com/maxogden/extract-zip/
|
|
3
|
-
// License: BSD-2-Clause
|
|
4
|
-
// Adapted to extract from buffer instead of file
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.downloadAndExtract = void 0;
|
|
7
|
-
const node_fetch_1 = require("node-fetch");
|
|
8
|
-
const yauzl = require('yauzl');
|
|
9
|
-
const mkdirp = require('mkdirp');
|
|
10
|
-
const path = require("path");
|
|
11
|
-
const fs = require("fs");
|
|
12
|
-
const concat = require('concat-stream');
|
|
13
|
-
const debug = require('debug')('extract-zip');
|
|
14
|
-
async function downloadAndExtract(url, destination) {
|
|
15
|
-
// Node-unzip is unstable. In general, streaming zip files is not recommended, since the
|
|
16
|
-
// file info are all at the end.
|
|
17
|
-
// We use yauzl here, on an in-memory buffer. In general apps should not be larger than
|
|
18
|
-
// around 10-20MB, so it's fine to keep it all in memory.
|
|
19
|
-
const response = await (0, node_fetch_1.default)(url);
|
|
20
|
-
if (!response.ok) {
|
|
21
|
-
let errorBody = await response.text();
|
|
22
|
-
throw new Error('Failed to download app: ' + response.statusText + '\n' + errorBody);
|
|
23
|
-
}
|
|
24
|
-
const buffer = await response.buffer();
|
|
25
|
-
await new Promise((resolve, reject) => {
|
|
26
|
-
extract(buffer, { dir: destination }, (err) => {
|
|
27
|
-
if (err) {
|
|
28
|
-
reject(err);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
resolve();
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
return destination;
|
|
36
|
-
}
|
|
37
|
-
exports.downloadAndExtract = downloadAndExtract;
|
|
38
|
-
function extract(buffer, opts, cb) {
|
|
39
|
-
debug('creating target directory', opts.dir);
|
|
40
|
-
mkdirp(opts.dir, function (err) {
|
|
41
|
-
if (err)
|
|
42
|
-
return cb(err);
|
|
43
|
-
openZip();
|
|
44
|
-
});
|
|
45
|
-
function openZip() {
|
|
46
|
-
debug('opening buffer with opts', opts);
|
|
47
|
-
yauzl.fromBuffer(buffer, { lazyEntries: true }, function (err, zipfile) {
|
|
48
|
-
if (err)
|
|
49
|
-
return cb(err);
|
|
50
|
-
var cancelled = false;
|
|
51
|
-
zipfile.readEntry();
|
|
52
|
-
zipfile.on('end', function () {
|
|
53
|
-
if (!cancelled) {
|
|
54
|
-
debug('zip extraction complete');
|
|
55
|
-
cb();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
zipfile.on('entry', function (entry) {
|
|
59
|
-
if (cancelled) {
|
|
60
|
-
debug('skipping entry', entry.fileName, { cancelled: cancelled });
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
debug('zipfile entry', entry.fileName);
|
|
64
|
-
if (/^__MACOSX\//.test(entry.fileName)) {
|
|
65
|
-
// dir name starts with __MACOSX/
|
|
66
|
-
zipfile.readEntry();
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
extractEntry(entry, function (err) {
|
|
70
|
-
// if any extraction fails then abort everything
|
|
71
|
-
if (err) {
|
|
72
|
-
cancelled = true;
|
|
73
|
-
zipfile.close();
|
|
74
|
-
return cb(err);
|
|
75
|
-
}
|
|
76
|
-
debug('finished processing', entry.fileName);
|
|
77
|
-
zipfile.readEntry();
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
function extractEntry(entry, done) {
|
|
81
|
-
if (cancelled) {
|
|
82
|
-
debug('skipping entry extraction', entry.fileName, { cancelled: cancelled });
|
|
83
|
-
return setImmediate(done);
|
|
84
|
-
}
|
|
85
|
-
if (opts.onEntry) {
|
|
86
|
-
opts.onEntry(entry, zipfile);
|
|
87
|
-
}
|
|
88
|
-
var dest = path.join(opts.dir, entry.fileName);
|
|
89
|
-
// convert external file attr int into a fs stat mode int
|
|
90
|
-
var mode = (entry.externalFileAttributes >> 16) & 0xffff;
|
|
91
|
-
// check if it's a symlink or dir (using stat mode constants)
|
|
92
|
-
var IFMT = 61440;
|
|
93
|
-
var IFDIR = 16384;
|
|
94
|
-
var IFLNK = 40960;
|
|
95
|
-
var symlink = (mode & IFMT) === IFLNK;
|
|
96
|
-
var isDir = (mode & IFMT) === IFDIR;
|
|
97
|
-
// check for windows weird way of specifying a directory
|
|
98
|
-
// https://github.com/maxogden/extract-zip/issues/13#issuecomment-154494566
|
|
99
|
-
var madeBy = entry.versionMadeBy >> 8;
|
|
100
|
-
if (!isDir)
|
|
101
|
-
isDir = madeBy === 0 && entry.externalFileAttributes === 16;
|
|
102
|
-
// if no mode then default to default modes
|
|
103
|
-
if (mode === 0) {
|
|
104
|
-
if (isDir) {
|
|
105
|
-
if (opts.defaultDirMode)
|
|
106
|
-
mode = parseInt(opts.defaultDirMode, 10);
|
|
107
|
-
if (!mode)
|
|
108
|
-
mode = 493; // Default to 0755
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
if (opts.defaultFileMode)
|
|
112
|
-
mode = parseInt(opts.defaultFileMode, 10);
|
|
113
|
-
if (!mode)
|
|
114
|
-
mode = 420; // Default to 0644
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
debug('extracting entry', { filename: entry.fileName, isDir: isDir, isSymlink: symlink });
|
|
118
|
-
// reverse umask first (~)
|
|
119
|
-
var umask = ~process.umask();
|
|
120
|
-
// & with processes umask to override invalid perms
|
|
121
|
-
var procMode = mode & umask;
|
|
122
|
-
// always ensure folders are created
|
|
123
|
-
var destDir = dest;
|
|
124
|
-
if (!isDir)
|
|
125
|
-
destDir = path.dirname(dest);
|
|
126
|
-
debug('mkdirp', { dir: destDir });
|
|
127
|
-
mkdirp(destDir, function (err) {
|
|
128
|
-
if (err) {
|
|
129
|
-
debug('mkdirp error', destDir, { error: err });
|
|
130
|
-
cancelled = true;
|
|
131
|
-
return done(err);
|
|
132
|
-
}
|
|
133
|
-
if (isDir)
|
|
134
|
-
return done();
|
|
135
|
-
debug('opening read stream', dest);
|
|
136
|
-
zipfile.openReadStream(entry, function (err, readStream) {
|
|
137
|
-
if (err) {
|
|
138
|
-
debug('openReadStream error', err);
|
|
139
|
-
cancelled = true;
|
|
140
|
-
return done(err);
|
|
141
|
-
}
|
|
142
|
-
readStream.on('error', function (err) {
|
|
143
|
-
console.log('read err', err);
|
|
144
|
-
});
|
|
145
|
-
if (symlink)
|
|
146
|
-
writeSymlink();
|
|
147
|
-
else
|
|
148
|
-
writeStream();
|
|
149
|
-
function writeStream() {
|
|
150
|
-
var writeStream = fs.createWriteStream(dest, { mode: procMode });
|
|
151
|
-
readStream.pipe(writeStream);
|
|
152
|
-
writeStream.on('finish', function () {
|
|
153
|
-
done();
|
|
154
|
-
});
|
|
155
|
-
writeStream.on('error', function (err) {
|
|
156
|
-
debug('write error', { error: err });
|
|
157
|
-
cancelled = true;
|
|
158
|
-
return done(err);
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
// AFAICT the content of the symlink file itself is the symlink target filename string
|
|
162
|
-
function writeSymlink() {
|
|
163
|
-
readStream.pipe(concat(function (data) {
|
|
164
|
-
var link = data.toString();
|
|
165
|
-
debug('creating symlink', link, dest);
|
|
166
|
-
fs.symlink(link, dest, function (err) {
|
|
167
|
-
if (err)
|
|
168
|
-
cancelled = true;
|
|
169
|
-
done(err);
|
|
170
|
-
});
|
|
171
|
-
}));
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
//# sourceMappingURL=unzip.js.map
|
package/dist/unzip.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unzip.js","sourceRoot":"","sources":["../src/unzip.ts"],"names":[],"mappings":";AAAA,wDAAwD;AACxD,wBAAwB;AACxB,iDAAiD;;;AAEjD,2CAA+B;AAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AACjC,6BAA6B;AAC7B,yBAAyB;AACzB,MAAM,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AACxC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CAAC;AAEvC,KAAK,UAAU,kBAAkB,CAAC,GAAW,EAAE,WAAmB;IACvE,wFAAwF;IACxF,gCAAgC;IAChC,uFAAuF;IACvF,yDAAyD;IAEzD,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QAChB,IAAI,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,0BAA0B,GAAG,QAAQ,CAAC,UAAU,GAAG,IAA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E;gCACvB,IAAI,EAAE,CAAC;4BACT,CAAC,CAAC,CAAC;4BAEH,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,GAAG;gCACnC,KAAK,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;gCACrC,SAAS,GAAG,IAAI,CAAC;gCACjB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;4BACnB,CAAC,CAAC,CAAC;wBACL,CAAC;wBAED,sFAAsF;wBACtF,SAAS,YAAY;4BACnB,UAAU,CAAC,IAAI,CACb,MAAM,CAAC,UAAU,IAAI;gCACnB,IAAI,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;gCAC3B,KAAK,CAAC,kBAAkB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;gCACtC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,UAAU,GAAG;oCAClC,IAAI,GAAG;wCAAE,SAAS,GAAG,IAAI,CAAC;oCAC1B,IAAI,CAAC,GAAG,CAAC,CAAC;gCACZ,CAAC,CAAC,CAAC;4BACL,CAAC,CAAC,CACH,CAAC;wBACJ,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
package/dist/upload.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function uploadZip(src: string, url: string): Promise<void>;
|
package/dist/upload.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uploadZip = void 0;
|
|
4
|
-
const jetpack = require("fs-jetpack");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const node_fetch_1 = require("node-fetch");
|
|
7
|
-
async function uploadZip(src, url) {
|
|
8
|
-
var info = await jetpack.inspect(src);
|
|
9
|
-
var stream = fs.createReadStream(src);
|
|
10
|
-
var response = await (0, node_fetch_1.default)(url, {
|
|
11
|
-
method: 'PUT',
|
|
12
|
-
headers: {
|
|
13
|
-
'Content-Type': 'application/zip',
|
|
14
|
-
'Content-Length': info.size
|
|
15
|
-
},
|
|
16
|
-
body: stream
|
|
17
|
-
});
|
|
18
|
-
if (response.status != 200) {
|
|
19
|
-
throw new Error(response.statusText + ': ' + (await response.text()));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.uploadZip = uploadZip;
|
|
23
|
-
//# sourceMappingURL=upload.js.map
|
package/dist/upload.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../src/upload.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AACtC,yBAAyB;AACzB,2CAA+B;AAExB,KAAK,UAAU,SAAS,CAAC,GAAW,EAAE,GAAW;IACtD,IAAI,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,MAAM,GAAG,EAAE,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,QAAQ,GAAG,MAAM,IAAA,oBAAK,EAAC,GAAG,EAAE;QAC9B,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,cAAc,EAAE,iBAAiB;YACjC,gBAAgB,EAAE,IAAI,CAAC,IAAI;SAC5B;QACD,IAAI,EAAE,MAAM;KACb,CAAC,CAAC;IACH,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,GAAG,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;KACvE;AACH,CAAC;AAdD,8BAcC"}
|