quickbundle 0.0.0-next-da5d78a → 0.0.0-next-68182ec

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.
Files changed (3) hide show
  1. package/README.md +10 -10
  2. package/dist/index.mjs +30 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -113,7 +113,7 @@ yarn add quickbundle
113
113
  "name": "lib", // Package name
114
114
  "source": "./src/index.ts", // Source code entry point. Make sure that it starts with `#!/usr/bin/env node` pragme to make the binary portable for consumers who would like to use it by installing the package instead of using the generated standalone executable.
115
115
  "bin": {
116
- "your-binary-name": "./dist/index.cjs", // Binary information to get the executable name from the key and, from the value, the bundled file to generate from the source code and inject into the executable. The generated executable will be located in the same folder as the bundled file and, by default, dependending on the current operating system running the `compile` command, the executable will be named either `your-binary-name.exe` on Windows or `your-binary-name` on Linux and macOS.
116
+ "your-binary-name": "./dist/index.cjs", // Binary information to get the executable name from the key and, from the value, the bundled file to generate from the source code and inject into the executable. The generated executable will be located in the same folder as the bundled file and, by default, dependending on the current operating system running the `compile` command, the executable will be named either `your-binary-name.exe` on Windows or `your-binary-name` on Linux and macOS. For cross-compilation output, check the `Patterns` section.
117
117
  },
118
118
  // "bin": "./dist/index.cjs", // Or, if the binary name follows the package name, you can define a string-based `bin` value.
119
119
  "scripts": {
@@ -173,21 +173,21 @@ Enabling source map generation is needed only if a build is [obfuscated (minifie
173
173
 
174
174
  ### Cross compilation to other platforms
175
175
 
176
- By default, the `compile` command embeds the runtime at the origin of its execution which means it generates executables compatible only with machines running the same operating system and processor architecture.
176
+ By default, the `compile` command embeds the runtime at the origin of its execution which means it generates executables compatible only with machines running the same operating system, processor architecture, and Node.js version.
177
177
 
178
- However, Quickbundle provides the ability to target a different operating system or processor architecture (also known as cross compilation):
178
+ However, Quickbundle provides the ability to target a different operating system, processor architecture, or Node.js version (also known as cross-compilation):
179
179
 
180
180
  ```bash
181
- quickbundle compile --runtime node-v23.1.0-darwin-arm64 # Embeds Node v23 runtime built for macOS ARM64 target
182
- quickbundle compile --runtime node-v23.1.0-darwin-x64 # Embeds Node v23 runtime built for macOS X64 target
183
- quickbundle compile --runtime node-v23.1.0-linux-arm64 # Embeds Node v23 runtime built for Linux ARM64 target
184
- quickbundle compile --runtime node-v23.1.0-linux-x64 # Embeds Node v23 runtime built for Linux X64 target
185
- quickbundle compile --runtime node-v23.1.0-win-arm64 # Embeds Node v23 runtime built for Windows ARM64 target
186
- quickbundle compile --runtime node-v23.1.0-win-x64 # Embeds Node v23 runtime built for Windows X64 target
181
+ quickbundle compile --target node-v23.1.0-darwin-arm64 # Embeds Node v23 runtime built for macOS ARM64 target
182
+ quickbundle compile --target node-v23.1.0-darwin-x64 # Embeds Node v23 runtime built for macOS X64 target
183
+ quickbundle compile --target node-v23.1.0-linux-arm64 # Embeds Node v23 runtime built for Linux ARM64 target
184
+ quickbundle compile --target node-v23.1.0-linux-x64 # Embeds Node v23 runtime built for Linux X64 target
185
+ quickbundle compile --target node-v23.1.0-win-arm64 # Embeds Node v23 runtime built for Windows ARM64 target
186
+ quickbundle compile --target node-v23.1.0-win-x64 # Embeds Node v23 runtime built for Windows X64 target
187
187
  ```
188
188
 
189
189
  > [!note]
190
- > The accepted runtime input are the one listed in [https://nodejs.org/download/release/vx.y.z](https://nodejs.org/download/release/latest/) with the following format `node-vx.y.z-(darwin|linux|win)-(arm64|x64|x86)`.
190
+ > The accepted target input follows the `node-vx.y.z-(darwin|linux|win)-(arm64|x64|x86)` format (for an exhaustive view, check available filenames in [https://nodejs.org/download/release/vx.y.z](https://nodejs.org/download/release/latest/)).
191
191
 
192
192
  <br>
193
193
 
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { finished } from 'node:stream/promises';
3
3
  import { Readable } from 'node:stream';
4
4
  import process from 'node:process';
5
5
  import { resolve, dirname, join, basename } from 'node:path';
6
- import { copyFile as copyFile$1, rm, writeFile as writeFile$1, rename, mkdir, readFile as readFile$1 } from 'node:fs/promises';
6
+ import { mkdir, copyFile as copyFile$1, rm, writeFile as writeFile$1, rename, readFile as readFile$1 } from 'node:fs/promises';
7
7
  import { createWriteStream } from 'node:fs';
8
8
  import decompress from 'decompress';
9
9
  import { watch as watch$1, rollup } from 'rollup';
@@ -19,7 +19,7 @@ import os from 'node:os';
19
19
  import { gzipSize } from 'gzip-size';
20
20
 
21
21
  var name = "quickbundle";
22
- var version = "0.0.0-next-da5d78a";
22
+ var version = "0.0.0-next-68182ec";
23
23
 
24
24
  /**
25
25
  * Resolve a relative path from the Quickbundle node modules directory.
@@ -67,12 +67,21 @@ const writeFile = async (filePath, content)=>{
67
67
  await writeFile$1(filePath, content, "utf8");
68
68
  };
69
69
  const download = async (url, filePath)=>{
70
- await createDirectory(dirname(filePath));
71
- const { body } = await fetch(url);
72
- if (!body) {
73
- throw new Error(`Empty body while attempting to download file from \`${url}\`.`);
70
+ try {
71
+ await createDirectory(dirname(filePath));
72
+ const { body, ok, status, statusText } = await fetch(url);
73
+ console.log({
74
+ ok,
75
+ status,
76
+ statusText
77
+ });
78
+ if (!body) {
79
+ throw new Error(`Empty body while attempting to download file from \`${url}\`.`);
80
+ }
81
+ await finished(Readable.fromWeb(body).pipe(createWriteStream(filePath)));
82
+ } catch (error) {
83
+ console.error("An error occurred while donwloading", error);
74
84
  }
75
- return finished(Readable.fromWeb(body).pipe(createWriteStream(filePath)));
76
85
  };
77
86
  const unzip = async (input, output)=>{
78
87
  const { targetArchivePath } = input;
@@ -393,12 +402,12 @@ const createCompileCommand = (program)=>{
393
402
  name: "compile",
394
403
  description: "Compiles the source code into a self-contained executable"
395
404
  }).option({
396
- key: "runtimeInput",
405
+ key: "targetInput",
397
406
  name: {
398
- long: "runtime",
399
- short: "r"
407
+ long: "target",
408
+ short: "t"
400
409
  },
401
- description: "Set a different runtime target than the one available in the local machine running the command.",
410
+ description: "Set a different cross-compilation target",
402
411
  defaultValue: "local"
403
412
  }).task({
404
413
  key: "config",
@@ -412,24 +421,27 @@ const createCompileCommand = (program)=>{
412
421
  }
413
422
  }).task({
414
423
  key: "osType",
415
- label ({ runtimeInput }) {
416
- return `Get runtime \`${runtimeInput}\``;
424
+ label ({ targetInput }) {
425
+ return `Get \`${targetInput}\` runtime`;
417
426
  },
418
- async handler ({ runtimeInput }) {
419
- if (runtimeInput === "local") {
427
+ async handler ({ targetInput }) {
428
+ if (targetInput === "local") {
420
429
  await copyFile(process.execPath, TEMPORARY_RUNTIME_PATH);
421
430
  return getOsType(os.type());
422
431
  }
423
- const matchedRuntimeParts = matchRuntimeParts(runtimeInput);
432
+ const matchedRuntimeParts = matchRuntimeParts(targetInput);
424
433
  if (!matchedRuntimeParts) {
425
434
  throw new Error("Invalid `runtime` flag input. The accepted targets are the one listed in https://nodejs.org/download/release/ with the following format `node-vx.y.z-(darwin|linux|win)-(arm64|x64|x86)`.");
426
435
  }
427
436
  const osType = getOsType(matchedRuntimeParts.os);
428
437
  const extension = osType === "windows" ? "zip" : "tar.gz";
429
- await download(`https://nodejs.org/download/release/${matchedRuntimeParts.version}/${runtimeInput}.${extension}`, TEMPORARY_DOWNLOAD_PATH);
438
+ await createDirectory(dirname(TEMPORARY_DOWNLOAD_PATH));
439
+ await download(`https://nodejs.org/download/release/${matchedRuntimeParts.version}/${targetInput}.${extension}`, TEMPORARY_DOWNLOAD_PATH);
440
+ console.log("LS -AL", await helpers.exec(`ls ${TEMPORARY_PATH} -al`));
441
+ console.log("LS -AL DOWNLOAD", await helpers.exec(`ls ${TEMPORARY_DOWNLOAD_PATH} -al`));
430
442
  await unzip({
431
443
  path: TEMPORARY_DOWNLOAD_PATH,
432
- targetArchivePath: osType === "windows" ? join(runtimeInput, "node.exe") : join(runtimeInput, "bin", "node")
444
+ targetArchivePath: osType === "windows" ? join(targetInput, "node.exe") : join(targetInput, "bin", "node")
433
445
  }, {
434
446
  directoryPath: dirname(TEMPORARY_RUNTIME_PATH),
435
447
  filename: basename(TEMPORARY_RUNTIME_PATH)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quickbundle",
3
- "version": "0.0.0-next-da5d78a",
3
+ "version": "0.0.0-next-68182ec",
4
4
  "description": "The zero-configuration transpiler and bundler for the web",
5
5
  "author": {
6
6
  "name": "Ayoub Adib",