@journeyapps/cloudcode-build-agent 0.0.0-dev.d5db5f6 → 0.0.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/defs.js +4 -4
- package/dist/defs.js.map +1 -1
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +21 -0
- package/dist/errors.js.map +1 -0
- package/dist/utils.d.ts +11 -0
- package/dist/utils.js +130 -0
- package/dist/utils.js.map +1 -0
- package/package.json +1 -1
package/dist/defs.js
CHANGED
|
@@ -13,25 +13,25 @@ exports.SUPPORTED_VERSIONS = [
|
|
|
13
13
|
{
|
|
14
14
|
version: '1.12.0',
|
|
15
15
|
node: '16.19.1',
|
|
16
|
-
builder_package: '@journeyapps/cloudcode-build-legacy',
|
|
16
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0',
|
|
17
17
|
builder_script: 'cloudcode-build-legacy'
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
version: '1.11.2',
|
|
21
21
|
node: '14.21.3',
|
|
22
|
-
builder_package: '@journeyapps/cloudcode-build-legacy',
|
|
22
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0',
|
|
23
23
|
builder_script: 'cloudcode-build-legacy'
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
version: '1.11.1',
|
|
27
27
|
node: '14.21.3',
|
|
28
|
-
builder_package: '@journeyapps/cloudcode-build-legacy',
|
|
28
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0',
|
|
29
29
|
builder_script: 'cloudcode-build-legacy'
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
version: '1.11.0',
|
|
33
33
|
node: '14.21.3',
|
|
34
|
-
builder_package: '@journeyapps/cloudcode-build-legacy',
|
|
34
|
+
builder_package: '@journeyapps/cloudcode-build-legacy@1.12.0',
|
|
35
35
|
builder_script: 'cloudcode-build-legacy'
|
|
36
36
|
}
|
|
37
37
|
];
|
package/dist/defs.js.map
CHANGED
|
@@ -1 +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,4DAA4D;IAC5D,sCAAsC;IACtC,KAAK;IACL;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,
|
|
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,4DAA4D;IAC5D,sCAAsC;IACtC,KAAK;IACL;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,4CAA4C;QAC7D,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,4CAA4C;QAC7D,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,4CAA4C;QAC7D,cAAc,EAAE,wBAAwB;KACzC;IACD;QACE,OAAO,EAAE,QAAQ;QACjB,IAAI,EAAE,SAAS;QACf,eAAe,EAAE,4CAA4C;QAC7D,cAAc,EAAE,wBAAwB;KACzC;CACF,CAAC"}
|
package/dist/errors.d.ts
ADDED
package/dist/errors.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/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/utils.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function downloadAndInstallNode(node_version: string, destination: string): Promise<{
|
|
2
|
+
bin_path: string;
|
|
3
|
+
node_bin: string;
|
|
4
|
+
npm_bin: string;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function nodePaths(destination: string): {
|
|
7
|
+
bin_path: string;
|
|
8
|
+
node_bin: string;
|
|
9
|
+
npm_bin: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function downloadAndExtractTarball(url: string, dest: string): Promise<void>;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.downloadAndExtractTarball = exports.nodePaths = exports.downloadAndInstallNode = void 0;
|
|
30
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
31
|
+
const path = __importStar(require("node:path"));
|
|
32
|
+
const fs = __importStar(require("node:fs"));
|
|
33
|
+
const os = __importStar(require("node:os"));
|
|
34
|
+
const URL = __importStar(require("node:url"));
|
|
35
|
+
const tar = __importStar(require("tar"));
|
|
36
|
+
/* Basically this, but for different dirs.
|
|
37
|
+
curl https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-${PLATFORM}64.tar.gz -L | tar -xzC /node-dedicated && \
|
|
38
|
+
mv /node-dedicated/node-v${NODE_VERSION}-linux-${PLATFORM}64/bin/node /node-dedicated/node
|
|
39
|
+
*/
|
|
40
|
+
// TODO: feature to find the latest minor and patch for a given major version?
|
|
41
|
+
async function downloadAndInstallNode(node_version, destination) {
|
|
42
|
+
// eg. https://nodejs.org/dist/v18.14.2/node-v18.14.2-linux-x64.tar.xz
|
|
43
|
+
// const PLATFORM = 'x';
|
|
44
|
+
// const node_download_url = `https://nodejs.org/dist/v${node_version}/node-v${node_version}-linux-${PLATFORM}64.tar.gz`;
|
|
45
|
+
// TODO: this is just for dev for now. Find a better fix.
|
|
46
|
+
const ARCH = os.arch();
|
|
47
|
+
const PLATFORM = os.platform();
|
|
48
|
+
const node_download_url = `https://nodejs.org/dist/v${node_version}/node-v${node_version}-${PLATFORM}-${ARCH}.tar.gz`;
|
|
49
|
+
await downloadAndExtractTarball(node_download_url, destination);
|
|
50
|
+
// TODO: move binaries into local bin path?
|
|
51
|
+
return nodePaths(destination);
|
|
52
|
+
}
|
|
53
|
+
exports.downloadAndInstallNode = downloadAndInstallNode;
|
|
54
|
+
function nodePaths(destination) {
|
|
55
|
+
return {
|
|
56
|
+
bin_path: path.resolve(destination, 'bin'),
|
|
57
|
+
node_bin: path.resolve(destination, 'bin', 'node'),
|
|
58
|
+
npm_bin: path.resolve(destination, 'bin', 'npm')
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.nodePaths = nodePaths;
|
|
62
|
+
async function downloadAndExtractTarball(url, dest) {
|
|
63
|
+
const tmpdir = os.tmpdir();
|
|
64
|
+
const filename = path.basename(URL.parse(url).pathname);
|
|
65
|
+
const base = path.basename(filename, '.tar.gz');
|
|
66
|
+
const download = path.join(tmpdir, filename);
|
|
67
|
+
if (fs.existsSync(download)) {
|
|
68
|
+
console.debug(`deleting old ${download}`);
|
|
69
|
+
fs.unlinkSync(download);
|
|
70
|
+
}
|
|
71
|
+
await new Promise(async (resolve, reject) => {
|
|
72
|
+
console.log(`fetching ${url} into ${download}`);
|
|
73
|
+
const response = await (0, node_fetch_1.default)(url);
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
const errorBody = await response.statusText;
|
|
76
|
+
throw new Error(`Failed to download: ${errorBody}`);
|
|
77
|
+
}
|
|
78
|
+
// FIXME: replace with webstreams? but according to the types package webstreams aren't available in node 16?!??
|
|
79
|
+
const file = fs.createWriteStream(download); // Sink the download stream into a file, so it can be extracted.
|
|
80
|
+
response.body.pipe(file);
|
|
81
|
+
file.on('finish', async () => {
|
|
82
|
+
try {
|
|
83
|
+
console.log('Extracting...', download);
|
|
84
|
+
// const comp = fs.createReadStream(download);
|
|
85
|
+
tar.extract({
|
|
86
|
+
cwd: tmpdir,
|
|
87
|
+
file: download,
|
|
88
|
+
sync: true
|
|
89
|
+
});
|
|
90
|
+
const uncomp = path.join(tmpdir, base);
|
|
91
|
+
const dist = path.resolve(dest);
|
|
92
|
+
// FIXME: dangerous. Add protection or replace.
|
|
93
|
+
// if (fs.existsSync(dist)) {
|
|
94
|
+
// fs.rmSync(dist, { recursive: true });
|
|
95
|
+
// }
|
|
96
|
+
if (fs.existsSync(uncomp)) {
|
|
97
|
+
console.log(`Moving extracted files from ${uncomp} to ${dist}`);
|
|
98
|
+
fs.renameSync(uncomp, dist);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
console.log(`Can't find extract dir ${uncomp}`);
|
|
102
|
+
}
|
|
103
|
+
// FIXME: this seems to sometimes cause errors
|
|
104
|
+
/*
|
|
105
|
+
----
|
|
106
|
+
node:events:505
|
|
107
|
+
throw er; // Unhandled 'error' event
|
|
108
|
+
^
|
|
109
|
+
|
|
110
|
+
Error: ENOENT: no such file or directory, open '/var/folders/kc/h6m4zpmd23v13s63mygvkslm0000gn/T/node-v16.19.1-darwin-arm64.tar.gz'
|
|
111
|
+
Emitted 'error' event on ReadStream instance at:
|
|
112
|
+
at emitErrorNT (node:internal/streams/destroy:157:8)
|
|
113
|
+
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
|
|
114
|
+
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
|
|
115
|
+
errno: -2,
|
|
116
|
+
code: 'ENOENT',
|
|
117
|
+
syscall: 'open',
|
|
118
|
+
path: '/var/folders/kc/h6m4zpmd23v13s63mygvkslm0000gn/T/node-v16.19.1-darwin-arm64.tar.gz'
|
|
119
|
+
*/
|
|
120
|
+
// fs.unlinkSync(file.path);
|
|
121
|
+
resolve(null);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
reject(err);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
exports.downloadAndExtractTarball = downloadAndExtractTarball;
|
|
130
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA+B;AAC/B,gDAAkC;AAClC,4CAA8B;AAC9B,4CAA8B;AAC9B,8CAAgC;AAChC,yCAA2B;AAE3B;;;EAGE;AACF,8EAA8E;AACvE,KAAK,UAAU,sBAAsB,CAAC,YAAoB,EAAE,WAAmB;IACpF,sEAAsE;IAEtE,wBAAwB;IACxB,yHAAyH;IAEzH,yDAAyD;IACzD,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;I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A4B;gBAE5B,OAAO,CAAC,IAAI,CAAC,CAAC;aACf;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,GAAG,CAAC,CAAC;aACb;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA5ED,8DA4EC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@journeyapps/cloudcode-build-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
4
|
"description": "Detect CloudCode tasks in a JourneyApps App and build them for installation on AWS Lambda",
|
|
5
5
|
"main": "./dist/index",
|
|
6
6
|
"types": "./dist/index",
|