@journeyapps/cloudcode-build-agent 0.0.0-dev.90a9f01 → 0.0.0-dev.9117f43
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/builder.d.ts +22 -1
- package/dist/builder.js +106 -5
- package/dist/builder.js.map +1 -1
- package/dist/cli.js +22 -22
- package/dist/cli.js.map +1 -1
- package/dist/defs.d.ts +7 -0
- package/dist/defs.js +43 -0
- package/dist/defs.js.map +1 -0
- package/dist/detect_tasks.d.ts +20 -0
- package/dist/detect_tasks.js +105 -0
- package/dist/detect_tasks.js.map +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +19 -1
- package/dist/installer.js +102 -73
- package/dist/installer.js.map +1 -1
- package/dist/run.d.ts +3 -0
- package/dist/run.js +18 -0
- package/dist/run.js.map +1 -0
- package/dist/spawn-stream.d.ts +14 -0
- package/dist/spawn-stream.js +58 -0
- package/dist/spawn-stream.js.map +1 -0
- package/package.json +21 -11
- package/dist/errors.d.ts +0 -8
- package/dist/errors.js +0 -21
- package/dist/errors.js.map +0 -1
- package/dist/utils.d.ts +0 -2
- package/dist/utils.js +0 -83
- package/dist/utils.js.map +0 -1
- package/src/builder.ts +0 -7
- package/src/cli.ts +0 -60
- package/src/errors.ts +0 -22
- package/src/index.ts +0 -3
- package/src/installer.ts +0 -88
- package/src/utils.ts +0 -63
- package/tsconfig.json +0 -9
- package/tsconfig.tsbuildinfo +0 -1
package/dist/builder.d.ts
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import { DetectedTask } from './detect_tasks';
|
|
2
|
+
export type GeneralTaskConfig = {
|
|
3
|
+
app_id: string;
|
|
4
|
+
env: string;
|
|
5
|
+
backend_id: string;
|
|
6
|
+
backend_url: string;
|
|
7
|
+
};
|
|
8
|
+
export type BuildOptions = {
|
|
9
|
+
only?: string;
|
|
10
|
+
custom_node_installation_path?: string;
|
|
11
|
+
};
|
|
12
|
+
type ToolPaths = {
|
|
13
|
+
bin_path: string;
|
|
14
|
+
node_bin: string;
|
|
15
|
+
npm_bin: string;
|
|
16
|
+
npx_bin: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function buildTasks(project_path: string, dest: string, config: GeneralTaskConfig, options?: BuildOptions): Promise<void>;
|
|
19
|
+
export declare function buildTask(task: DetectedTask, project_path: string, dest: string, config: GeneralTaskConfig, node_context: {
|
|
20
|
+
node_version: string;
|
|
21
|
+
} & ToolPaths): Promise<void>;
|
|
22
|
+
export {};
|
package/dist/builder.js
CHANGED
|
@@ -1,9 +1,110 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildTasks = void 0;
|
|
4
|
-
// Detect tasks in given path and build them.
|
|
5
|
-
async function buildTasks(src, dest, only) { }
|
|
6
26
|
exports.buildTasks = buildTasks;
|
|
7
|
-
|
|
8
|
-
|
|
27
|
+
exports.buildTask = buildTask;
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const jetpack = __importStar(require("fs-jetpack"));
|
|
30
|
+
const semver = __importStar(require("semver"));
|
|
31
|
+
const installer_1 = require("./installer");
|
|
32
|
+
const detect_tasks_1 = require("./detect_tasks");
|
|
33
|
+
const run_1 = require("./run");
|
|
34
|
+
async function buildTasks(project_path, dest, config, options) {
|
|
35
|
+
const tasks = await (0, detect_tasks_1.detectTasks)(project_path, options?.only);
|
|
36
|
+
// Use the version of nodejs that's running this script as the default.
|
|
37
|
+
const default_tool_paths = {
|
|
38
|
+
bin_path: path.dirname(process.execPath),
|
|
39
|
+
node_bin: process.execPath,
|
|
40
|
+
npm_bin: path.join(path.dirname(process.execPath), 'npm'),
|
|
41
|
+
npx_bin: path.join(path.dirname(process.execPath), 'npx')
|
|
42
|
+
};
|
|
43
|
+
for (const task of tasks) {
|
|
44
|
+
let custom_tool_paths;
|
|
45
|
+
if (task.required_node_version) {
|
|
46
|
+
// FIXME: when defaulting to project_path, the custom node installation is copied into the builder's workdir as well.
|
|
47
|
+
const custom_node_installation_path = options?.custom_node_installation_path ?? project_path;
|
|
48
|
+
const custom_node_path = path.resolve(custom_node_installation_path, `node-${semver.major(task.required_node_version)}`);
|
|
49
|
+
custom_tool_paths = await (0, installer_1.ensureCustomNodeVersion)(task.required_node_version, custom_node_path);
|
|
50
|
+
}
|
|
51
|
+
const node_version = task.required_node_version ?? process.version;
|
|
52
|
+
await buildTask(task, project_path, dest, config, {
|
|
53
|
+
node_version,
|
|
54
|
+
...(custom_tool_paths ?? default_tool_paths)
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
async function buildTask(task, project_path, dest, config, node_context) {
|
|
59
|
+
const builder_package = task.builder_package;
|
|
60
|
+
const builder_script = task.builder_script;
|
|
61
|
+
const { node_bin, npm_bin, npx_bin } = node_context;
|
|
62
|
+
if (!jetpack.exists(node_bin)) {
|
|
63
|
+
throw new Error(`Node binary not found: ${node_bin}`);
|
|
64
|
+
}
|
|
65
|
+
console.debug(`[${task.task_name}] Installing builder script "${builder_package}" for node ${node_context.node_version}`);
|
|
66
|
+
/*
|
|
67
|
+
* The builder package is installed locally so as to not require write access to the global node installation,
|
|
68
|
+
* and executed with npx to handle the path resoluton, etc.
|
|
69
|
+
*/
|
|
70
|
+
const stream1 = (0, run_1.runCommand)(node_bin, [npm_bin, '--no-save', '--no-fund', '--no-audit', 'install', builder_package], {
|
|
71
|
+
cwd: project_path,
|
|
72
|
+
env: {
|
|
73
|
+
npm_config_loglevel: 'error', // Suppress noisy "WARN" messages.
|
|
74
|
+
...process.env
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
for await (let event of stream1) {
|
|
78
|
+
const log = event.stdout ?? event.stderr;
|
|
79
|
+
if (log) {
|
|
80
|
+
console.log(`[${task.task_name} - install]`, log.trimRight());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const build_metadata = {
|
|
84
|
+
name: task.task_name,
|
|
85
|
+
version: task.task_version,
|
|
86
|
+
lambda_runtime: task.task_runtime,
|
|
87
|
+
user_config: task.user_task_config
|
|
88
|
+
};
|
|
89
|
+
await jetpack.writeAsync(path.join(dest, `${task.task_name}-metadata.json`), JSON.stringify(build_metadata));
|
|
90
|
+
const builder_args = [];
|
|
91
|
+
builder_args.push(builder_script);
|
|
92
|
+
builder_args.push('--src', project_path);
|
|
93
|
+
builder_args.push(`--out`, path.join(dest, task.task_name));
|
|
94
|
+
builder_args.push(`--zip`, path.join(dest, `${task.task_name}.zip`));
|
|
95
|
+
builder_args.push(`--task`, `${task.task_name}`);
|
|
96
|
+
builder_args.push(`--appId`, config.app_id);
|
|
97
|
+
builder_args.push(`--env`, config.env);
|
|
98
|
+
builder_args.push(`--backendId`, config.backend_id);
|
|
99
|
+
builder_args.push(`--backendUrl`, config.backend_url);
|
|
100
|
+
console.debug(`[${task.task_name}] Trying: ${node_bin} ${builder_args.join(' ')}`);
|
|
101
|
+
const stream2 = (0, run_1.runCommand)(npx_bin, ['--no-install', ...builder_args], { cwd: project_path, env: process.env });
|
|
102
|
+
for await (let event of stream2) {
|
|
103
|
+
const log = event.stdout ?? event.stderr;
|
|
104
|
+
if (log) {
|
|
105
|
+
console.log(`[${task.task_name} - build]`, log.trimRight());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
console.log(`[${task.task_name} - build]`, `Finished.`);
|
|
109
|
+
}
|
|
9
110
|
//# sourceMappingURL=builder.js.map
|
package/dist/builder.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,gCAkCC;AAED,8BAoEC;AAhID,gDAAkC;AAClC,oDAAsC;AACtC,+CAAiC;AAEjC,2CAAsD;AACtD,iDAA2D;AAC3D,+BAAmC;AAkB5B,KAAK,UAAU,UAAU,CAC9B,YAAoB,EACpB,IAAY,EACZ,MAAyB,EACzB,OAAsB;IAEtB,MAAM,KAAK,GAAG,MAAM,IAAA,0BAAW,EAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IAE7D,uEAAuE;IACvE,MAAM,kBAAkB,GAAG;QACzB,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;QACxC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,O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AAI,IAAI,CAAC,SAAS,WAAW,EAAE,WAAW,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/cli.js
CHANGED
|
@@ -27,26 +27,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
27
27
|
const yargs = __importStar(require("yargs"));
|
|
28
28
|
const _1 = require("./");
|
|
29
29
|
const DEFAULT_SRC_PATH = './';
|
|
30
|
-
const DEFAULT_OUT_PATH = '';
|
|
30
|
+
const DEFAULT_OUT_PATH = './dist/cloudcode';
|
|
31
|
+
const DEFAULT_TMP_PATH = '/tmp/cloudcode-build-agent/node';
|
|
31
32
|
yargs
|
|
32
33
|
.command(['build', '$0'], // $0 means this is the default command
|
|
33
34
|
'build tasks', (yargs) => {
|
|
34
|
-
return yargs
|
|
35
|
+
return (yargs
|
|
35
36
|
.option('only', { string: true })
|
|
36
37
|
.option('path', { default: DEFAULT_SRC_PATH })
|
|
37
|
-
.option('out', { default: DEFAULT_OUT_PATH })
|
|
38
|
+
.option('out', { default: DEFAULT_OUT_PATH })
|
|
39
|
+
.option('node_work_dir', { default: DEFAULT_TMP_PATH })
|
|
40
|
+
// TODO: investigate yargs.config() for reading task config blob from a file. But how to ensure required args?
|
|
41
|
+
.option('appId', { string: true, demandOption: true, describe: "CloudCode's reference id" })
|
|
42
|
+
.option('env', { string: true, demandOption: true })
|
|
43
|
+
.option('backendId', { string: true, demandOption: true })
|
|
44
|
+
.option('backendUrl', { string: true, demandOption: true }));
|
|
38
45
|
}, handled(async (argv) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
await (0, _1.prepareBuildEnvForTasks)(argv.path, argv.only);
|
|
46
|
+
const config = {
|
|
47
|
+
app_id: argv.appId,
|
|
48
|
+
env: argv.env,
|
|
49
|
+
backend_id: argv.backendId,
|
|
50
|
+
backend_url: argv.backendUrl
|
|
51
|
+
};
|
|
52
|
+
await (0, _1.buildTasks)(argv.path, argv.out, config, {
|
|
53
|
+
only: argv.only,
|
|
54
|
+
custom_node_installation_path: argv.node_work_dir
|
|
55
|
+
});
|
|
50
56
|
}))
|
|
51
57
|
.option('verbose', {
|
|
52
58
|
alias: 'v',
|
|
@@ -58,14 +64,8 @@ function handled(fn) {
|
|
|
58
64
|
await fn(argv);
|
|
59
65
|
}
|
|
60
66
|
catch (err) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
process.exit(err.status);
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
console.error(err.stack);
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
67
|
+
console.error(err.stack);
|
|
68
|
+
process.exit(1);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
}
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAA+B;AAE/B,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAA+B;AAE/B,yBAAgC;AAEhC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,gBAAgB,GAAG,kBAAkB,CAAC;AAC5C,MAAM,gBAAgB,GAAG,iCAAiC,CAAC;AAE3D,KAAK;KACF,OAAO,CACN,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,uCAAuC;AACxD,aAAa,EACb,CAAC,KAAK,EAAE,EAAE;IACR,OAAO,CACL,KAAK;SACF,MAAM,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;SAChC,MAAM,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;SAC7C,MAAM,CAAC,KAAK,EAAE,EA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G,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/defs.d.ts
ADDED
package/dist/defs.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUPPORTED_VERSIONS = void 0;
|
|
4
|
+
// TODO: maybe publish (some of) this from the CC service?
|
|
5
|
+
exports.SUPPORTED_VERSIONS = [
|
|
6
|
+
// {
|
|
7
|
+
// // proposed
|
|
8
|
+
// version: '1.13.0',
|
|
9
|
+
// node: '18.14.2',
|
|
10
|
+
// runtime: 'nodejs18.x',
|
|
11
|
+
// builder_package: '@journeyapps/cloudcode-build@1.13.0',
|
|
12
|
+
// builder_script: 'cloudcode-build'
|
|
13
|
+
// },
|
|
14
|
+
{
|
|
15
|
+
version: '1.12.0',
|
|
16
|
+
node: '16.19.1', // FIXME: maybe the very specific node version here is too brittle? Should we just specify the major version?
|
|
17
|
+
runtime: 'nodejs16.x',
|
|
18
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0-alpha.1',
|
|
19
|
+
builder_script: 'cloudcode-build-legacy'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
version: '1.11.2',
|
|
23
|
+
node: '14.21.3',
|
|
24
|
+
runtime: 'nodejs14.x',
|
|
25
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0-alpha.1',
|
|
26
|
+
builder_script: 'cloudcode-build-legacy'
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
version: '1.11.1',
|
|
30
|
+
node: '14.21.3',
|
|
31
|
+
runtime: 'nodejs14.x',
|
|
32
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0-alpha.1',
|
|
33
|
+
builder_script: 'cloudcode-build-legacy'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
version: '1.11.0',
|
|
37
|
+
node: '14.21.3',
|
|
38
|
+
runtime: 'nodejs14.x',
|
|
39
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0-alpha.1',
|
|
40
|
+
builder_script: 'cloudcode-build-legacy'
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
//# sourceMappingURL=defs.js.map
|
package/dist/defs.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defs.js","sourceRoot":"","sources":["../src/defs.ts"],"names":[],"mappings":";;;AAAA,0DAA0D;AAC7C,QAAA,kBAAkB,GAAG;IAChC,IAAI;IACJ,gBAAgB;IAChB,uBAAuB;IACvB,qBAAqB;IACrB,2BAA2B;IAC3B,4DAA4D;IAC5D,sCAAsC;IACtC,KAAK;IACL;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS,EAAE,6GAA6G;QAC9H,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,oDAAoD;QACrE,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,oDAAoD;QACrE,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,oDAAoD;QACrE,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,OAAO,EAAE,YAAY;QACrB,eAAe,EAAE,oDAAoD;QACrE,cAAc,EAAE,wBAAwB;KACzC;CACF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type DetectedTask = {
|
|
2
|
+
pkg_path: string;
|
|
3
|
+
task_name: string;
|
|
4
|
+
task_version: string;
|
|
5
|
+
task_runtime: string;
|
|
6
|
+
required_node_version?: string;
|
|
7
|
+
builder_package: string;
|
|
8
|
+
builder_script: string;
|
|
9
|
+
user_task_config: {
|
|
10
|
+
runtime: string;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
shared?: boolean;
|
|
13
|
+
serial?: boolean;
|
|
14
|
+
app?: boolean;
|
|
15
|
+
web?: boolean;
|
|
16
|
+
webhook?: boolean;
|
|
17
|
+
schedule?: any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export declare function detectTasks(project_path: string, only?: string): Promise<DetectedTask[]>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.detectTasks = detectTasks;
|
|
27
|
+
const fs = __importStar(require("node:fs"));
|
|
28
|
+
const path = __importStar(require("node:path"));
|
|
29
|
+
const jetpack = __importStar(require("fs-jetpack"));
|
|
30
|
+
const semver = __importStar(require("semver"));
|
|
31
|
+
const defs = __importStar(require("./defs"));
|
|
32
|
+
async function readPackage(path) {
|
|
33
|
+
try {
|
|
34
|
+
const content = await fs.promises.readFile(path, { encoding: 'utf-8' });
|
|
35
|
+
return JSON.parse(content);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
console.error(`ERROR: ${err}`);
|
|
39
|
+
throw err;
|
|
40
|
+
// todo: check for enoent and skip?
|
|
41
|
+
// todo: if json error, throw a CC build error?
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const UserTaskConfigDefaults = {
|
|
45
|
+
runtime: null, // Required field, but could be missing in ancient versions
|
|
46
|
+
enabled: true
|
|
47
|
+
};
|
|
48
|
+
async function detectTasks(project_path, only) {
|
|
49
|
+
const cloudcode_path = path.join(project_path, 'cloudcode');
|
|
50
|
+
if (!jetpack.exists(cloudcode_path)) {
|
|
51
|
+
return Promise.resolve([]);
|
|
52
|
+
}
|
|
53
|
+
const package_files = await jetpack.findAsync(cloudcode_path, { matching: '**/package.json' });
|
|
54
|
+
const filtered_package_files = package_files.filter((pkg_path) => {
|
|
55
|
+
// FIXME: this is kinda clunky.
|
|
56
|
+
const pm = /^\/?cloudcode\/([^\/]+)\/package\.json$/.exec(pkg_path);
|
|
57
|
+
if (!pm) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
const taskName = pm[1];
|
|
61
|
+
if (only != null && only != taskName) {
|
|
62
|
+
// !(only.indexOf(taskName) >= 0) // TODO: support a specific list of tasks to build?
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
return Promise.all(filtered_package_files.map(async (pkg_path) => {
|
|
68
|
+
const task_package = await readPackage(pkg_path);
|
|
69
|
+
const task_name = task_package.name; // CAVEAT: the pkg name _must_ match the dir.
|
|
70
|
+
const task_version = task_package.cloudcode.runtime;
|
|
71
|
+
const user_task_config = {
|
|
72
|
+
...UserTaskConfigDefaults,
|
|
73
|
+
...task_package.cloud_code
|
|
74
|
+
};
|
|
75
|
+
/* CAVEAT: We do not exclude disabled tasks from the build process, because this is a special case where the
|
|
76
|
+
processing for a task is disabled, but the resources for the task are not destroyed.
|
|
77
|
+
*/
|
|
78
|
+
console.debug(`Detected task version ${task_version}`);
|
|
79
|
+
const matching = defs.SUPPORTED_VERSIONS.find((v) => {
|
|
80
|
+
return semver.satisfies(v.version, task_version);
|
|
81
|
+
});
|
|
82
|
+
if (!matching) {
|
|
83
|
+
throw new Error('FIXME: unsupported version');
|
|
84
|
+
}
|
|
85
|
+
console.debug(`Matching versions: ${JSON.stringify(matching)}`);
|
|
86
|
+
const task_runtime = matching.runtime;
|
|
87
|
+
const running_node_version = process.versions.node;
|
|
88
|
+
let required_node_version;
|
|
89
|
+
if (matching?.node && semver.major(matching.node) !== semver.major(running_node_version)) {
|
|
90
|
+
console.debug(`Task requires different node version: v${matching.node}. Running: ${running_node_version}`);
|
|
91
|
+
required_node_version = matching.node;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
pkg_path,
|
|
95
|
+
task_name,
|
|
96
|
+
task_version,
|
|
97
|
+
task_runtime,
|
|
98
|
+
user_task_config,
|
|
99
|
+
required_node_version,
|
|
100
|
+
builder_package: matching.builder_package,
|
|
101
|
+
builder_script: matching.builder_script
|
|
102
|
+
};
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=detect_tasks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect_tasks.js","sourceRoot":"","sources":["../src/detect_tasks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA2CA,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,IAAI,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,oBAAoB,CAAC,EAAE,CAAC;YACzF,OAAO,CAAC,KAAK,CAAC,0CAA0C,QAAQ,CAAC,IAAI,cAAc,oBAAoB,EAAE,CAAC,CAAC;YAE3G,qBAAqB,GAAG,QAAQ,CAAC,IAAI,CAAC;QACxC,CAAC;QACD,OAAO;YACL,QAAQ;YACR,SAAS;YACT,YAAY;YACZ,YAAY;YACZ,gBAAgB;YAChB,qBAAqB;YACrB,eAAe,EAAE,QAAQ,CAAC,eAAe;YACzC,cAAc,EAAE,QAAQ,CAAC,cAAc;SACxC,CAAC;IACJ,CAAC,CAAC,CACH,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,7 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./errors"), exports);
|
|
18
17
|
__exportStar(require("./builder"), exports);
|
|
19
|
-
__exportStar(require("./installer"), exports);
|
|
20
18
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4CAA0B"}
|
package/dist/installer.d.ts
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function ensureCustomNodeVersion(node_version: string, install_path: string): Promise<{
|
|
2
|
+
bin_path: string;
|
|
3
|
+
node_bin: string;
|
|
4
|
+
npm_bin: string;
|
|
5
|
+
npx_bin: string;
|
|
6
|
+
}>;
|
|
7
|
+
export declare function downloadAndInstallNode(node_version: string, destination: string): Promise<{
|
|
8
|
+
bin_path: string;
|
|
9
|
+
node_bin: string;
|
|
10
|
+
npm_bin: string;
|
|
11
|
+
npx_bin: string;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function nodePaths(destination: string): {
|
|
14
|
+
bin_path: string;
|
|
15
|
+
node_bin: string;
|
|
16
|
+
npm_bin: string;
|
|
17
|
+
npx_bin: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function downloadAndExtractTarball(url: string, dest: string): Promise<void>;
|