sliftutils 0.1.1 → 0.3.0
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/builders/nodeJSBuild.ts +29 -0
- package/builders/nodeJSBuildRun.js +2 -0
- package/bundler/bundleEntry.ts +13 -8
- package/bundler/bundleEntryCaller.ts +7 -3
- package/package-lock.json +2311 -0
- package/package.json +12 -4
- package/spec.txt +17 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { delay } from "socket-function/src/batching";
|
|
3
|
+
import { bundleEntryCaller } from "../bundler/bundleEntryCaller";
|
|
4
|
+
import yargs from "yargs";
|
|
5
|
+
import { formatTime } from "socket-function/src/formatting/format";
|
|
6
|
+
|
|
7
|
+
async function main() {
|
|
8
|
+
let time = Date.now();
|
|
9
|
+
let yargObj = yargs(process.argv)
|
|
10
|
+
.option("entryPoint", { type: "string", default: "./server.ts", desc: `Path to the entry point file` })
|
|
11
|
+
.option("outputFolder", { type: "string", default: "./build-nodejs", desc: `Output folder` })
|
|
12
|
+
.argv || {}
|
|
13
|
+
;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// Wait for any async functions to load.
|
|
17
|
+
await delay(0);
|
|
18
|
+
|
|
19
|
+
await fs.promises.mkdir("./build-nodejs", { recursive: true });
|
|
20
|
+
|
|
21
|
+
await bundleEntryCaller({
|
|
22
|
+
entryPoint: yargObj.entryPoint,
|
|
23
|
+
outputFolder: "./build-nodejs",
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
let duration = Date.now() - time;
|
|
27
|
+
console.log(`NodeJS build completed in ${formatTime(duration)}`);
|
|
28
|
+
}
|
|
29
|
+
main().catch(console.error).finally(() => process.exit());
|
package/bundler/bundleEntry.ts
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { bundle } from "./bundler";
|
|
3
3
|
import fs from "fs";
|
|
4
|
+
import yargs from "yargs";
|
|
4
5
|
|
|
5
|
-
function getCommandLineArg(name: string) {
|
|
6
|
-
let index = process.argv.indexOf(name);
|
|
7
|
-
if (index === -1) return null;
|
|
8
|
-
return process.argv[index + 1];
|
|
9
|
-
}
|
|
10
6
|
async function main() {
|
|
11
|
-
let
|
|
7
|
+
let yargObj = yargs(process.argv)
|
|
8
|
+
.option("entryPoint", { type: "string", desc: `Path to the entry point file` })
|
|
9
|
+
.option("outputFolder", { type: "string", desc: `Path to the output folder` })
|
|
10
|
+
.argv || {}
|
|
11
|
+
;
|
|
12
|
+
let entryPoint = yargObj.entryPoint;
|
|
13
|
+
let outputFolder = yargObj.outputFolder;
|
|
12
14
|
if (!entryPoint) {
|
|
13
|
-
throw new Error("No entry point provided");
|
|
15
|
+
throw new Error("No entry point provided. Please use the --entryPoint option.");
|
|
16
|
+
}
|
|
17
|
+
if (!outputFolder) {
|
|
18
|
+
throw new Error("No output folder provided. Please use the --outputFolder option.");
|
|
14
19
|
}
|
|
15
20
|
require("../" + entryPoint);
|
|
16
21
|
|
|
@@ -27,6 +32,6 @@ async function main() {
|
|
|
27
32
|
rootPath: path.resolve("."),
|
|
28
33
|
entryPoints: [entryPoint],
|
|
29
34
|
});
|
|
30
|
-
await fs.promises.writeFile(
|
|
35
|
+
await fs.promises.writeFile(`${yargObj.outputFolder}/${name}`, bundled.bundle);
|
|
31
36
|
}
|
|
32
37
|
main().catch(console.error).finally(() => process.exit());
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import child_process from "child_process";
|
|
2
2
|
import { runPromise } from "socket-function/src/runPromise";
|
|
3
|
+
import shellQuote from "shell-quote";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export async function bundleEntryCaller(config: {
|
|
6
|
+
entryPoint: string;
|
|
7
|
+
outputFolder: string;
|
|
8
|
+
}) {
|
|
9
|
+
let { entryPoint, outputFolder } = config;
|
|
10
|
+
let command = shellQuote.quote(["yarn", "typenode", "./bundler/bundleEntry.ts", "--entryPoint", entryPoint, "--outputFolder", outputFolder]);
|
|
7
11
|
await runPromise(command);
|
|
8
12
|
}
|