@gjsify/cli 0.4.25 → 0.4.27

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.
@@ -27,11 +27,14 @@ export declare class BuildAction {
27
27
  private resolveGlobalsInject;
28
28
  /**
29
29
  * Post-processing: prepend the resolved shebang line and mark the
30
- * output executable. Only runs for GJS app builds with a single outfile.
31
- * The shebang plugin in `@gjsify/rolldown-plugin-gjsify` already injects
32
- * during bundling this hook is the safety net for anything that
33
- * bypassed the plugin (e.g. user-supplied banners that out-ordered it),
34
- * plus the chmod.
30
+ * output executable. Runs for GJS and Node app builds with a single
31
+ * outfile. The default line depends on the target — `gjs -m` for
32
+ * `--app gjs`, `node` for `--app node` so a single `shebang: true`
33
+ * config produces a directly-executable bin for whichever target is
34
+ * built. For GJS the shebang plugin already injects during bundling;
35
+ * this hook is the safety net for anything that bypassed it (e.g.
36
+ * user-supplied banners that out-ordered it) plus the chmod. For Node
37
+ * there is no in-bundle plugin, so this hook is the sole injection point.
35
38
  */
36
39
  private applyShebang;
37
40
  /** Application mode */
@@ -1,5 +1,5 @@
1
1
  import { runBundle, runWatch, bundleToChunks } from "../bundler-pick.js";
2
- import { gjsifyPlugin, textLoaderPlugin, resolveShebangLine } from "@gjsify/rolldown-plugin-gjsify";
2
+ import { gjsifyPlugin, textLoaderPlugin, resolveShebangLine, NODE_SHEBANG } from "@gjsify/rolldown-plugin-gjsify";
3
3
  import { resolveUserPlugins } from "../utils/resolve-plugin-by-name.js";
4
4
  import { resolveGlobalsList, writeRegisterInjectFile, detectAutoGlobals, } from "@gjsify/rolldown-plugin-gjsify/globals";
5
5
  import { pnpPlugin } from "@gjsify/rolldown-plugin-pnp";
@@ -152,19 +152,23 @@ export class BuildAction {
152
152
  }
153
153
  /**
154
154
  * Post-processing: prepend the resolved shebang line and mark the
155
- * output executable. Only runs for GJS app builds with a single outfile.
156
- * The shebang plugin in `@gjsify/rolldown-plugin-gjsify` already injects
157
- * during bundling this hook is the safety net for anything that
158
- * bypassed the plugin (e.g. user-supplied banners that out-ordered it),
159
- * plus the chmod.
155
+ * output executable. Runs for GJS and Node app builds with a single
156
+ * outfile. The default line depends on the target — `gjs -m` for
157
+ * `--app gjs`, `node` for `--app node` so a single `shebang: true`
158
+ * config produces a directly-executable bin for whichever target is
159
+ * built. For GJS the shebang plugin already injects during bundling;
160
+ * this hook is the safety net for anything that bypassed it (e.g.
161
+ * user-supplied banners that out-ordered it) plus the chmod. For Node
162
+ * there is no in-bundle plugin, so this hook is the sole injection point.
160
163
  */
161
- async applyShebang(outfile, verbose) {
164
+ async applyShebang(app, outfile, verbose) {
162
165
  if (!outfile) {
163
166
  if (verbose)
164
- console.warn("[gjsify] --shebang skipped: no single outfile (use --outfile for GJS executables)");
167
+ console.warn("[gjsify] --shebang skipped: no single outfile (use --outfile for executables)");
165
168
  return;
166
169
  }
167
- const line = resolveShebangLine(this.configData.shebang) ?? DEFAULT_GJS_SHEBANG;
170
+ const defaultLine = app === "node" ? NODE_SHEBANG : DEFAULT_GJS_SHEBANG;
171
+ const line = resolveShebangLine(this.configData.shebang, defaultLine) ?? defaultLine;
168
172
  const content = await readFile(outfile, "utf-8");
169
173
  if (content.startsWith("#!")) {
170
174
  if (verbose)
@@ -293,8 +297,8 @@ export class BuildAction {
293
297
  return [];
294
298
  }
295
299
  const writeResult = await runBundle(finalOpts);
296
- if (app === "gjs" && this.configData.shebang) {
297
- await this.applyShebang(outfile, verbose);
300
+ if ((app === "gjs" || app === "node") && this.configData.shebang) {
301
+ await this.applyShebang(app, outfile, verbose);
298
302
  }
299
303
  return [writeResult];
300
304
  }
@@ -336,8 +340,8 @@ export class BuildAction {
336
340
  case "BUNDLE_END":
337
341
  console.log(`[gjsify build --watch] built in ${event.duration}ms`);
338
342
  try {
339
- if (app === "gjs" && this.configData.shebang) {
340
- await this.applyShebang(outfile, verbose);
343
+ if ((app === "gjs" || app === "node") && this.configData.shebang) {
344
+ await this.applyShebang(app, outfile, verbose);
341
345
  }
342
346
  }
343
347
  finally {
@@ -102,7 +102,7 @@ export const buildCommand = {
102
102
  default: 'auto'
103
103
  })
104
104
  .option('shebang', {
105
- description: "Prepend a `#!/usr/bin/env -S gjs -m` shebang to the output and mark it executable (chmod 755). Only applies to GJS app builds with a single --outfile. Default: false (use --shebang to enable, or set `shebang: true` in `.gjsifyrc.js`).",
105
+ description: "Prepend a target-appropriate shebang to the output and mark it executable (chmod 755): `#!/usr/bin/env -S gjs -m` for --app gjs, `#!/usr/bin/env node` for --app node. Applies to GJS and Node app builds with a single --outfile. Default: false (use --shebang to enable, or set `shebang: true` in `.gjsifyrc.js`).",
106
106
  type: 'boolean',
107
107
  normalize: true
108
108
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/cli",
3
- "version": "0.4.25",
3
+ "version": "0.4.27",
4
4
  "description": "CLI for Gjsify",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -120,18 +120,18 @@
120
120
  "cli"
121
121
  ],
122
122
  "dependencies": {
123
- "@gjsify/buffer": "^0.4.25",
124
- "@gjsify/create-app": "^0.4.25",
125
- "@gjsify/node-globals": "^0.4.25",
126
- "@gjsify/node-polyfills": "^0.4.25",
127
- "@gjsify/npm-registry": "^0.4.25",
128
- "@gjsify/resolve-npm": "^0.4.25",
129
- "@gjsify/rolldown-plugin-gjsify": "^0.4.25",
130
- "@gjsify/rolldown-plugin-pnp": "^0.4.25",
131
- "@gjsify/semver": "^0.4.25",
132
- "@gjsify/tar": "^0.4.25",
133
- "@gjsify/web-polyfills": "^0.4.25",
134
- "@gjsify/workspace": "^0.4.25",
123
+ "@gjsify/buffer": "^0.4.27",
124
+ "@gjsify/create-app": "^0.4.27",
125
+ "@gjsify/node-globals": "^0.4.27",
126
+ "@gjsify/node-polyfills": "^0.4.27",
127
+ "@gjsify/npm-registry": "^0.4.27",
128
+ "@gjsify/resolve-npm": "^0.4.27",
129
+ "@gjsify/rolldown-plugin-gjsify": "^0.4.27",
130
+ "@gjsify/rolldown-plugin-pnp": "^0.4.27",
131
+ "@gjsify/semver": "^0.4.27",
132
+ "@gjsify/tar": "^0.4.27",
133
+ "@gjsify/web-polyfills": "^0.4.27",
134
+ "@gjsify/workspace": "^0.4.27",
135
135
  "cosmiconfig": "^9.0.1",
136
136
  "get-tsconfig": "^4.14.0",
137
137
  "pkg-types": "^2.3.1",
@@ -139,12 +139,12 @@
139
139
  "yargs": "^18.0.0"
140
140
  },
141
141
  "devDependencies": {
142
- "@gjsify/unit": "^0.4.25",
142
+ "@gjsify/unit": "^0.4.27",
143
143
  "@types/yargs": "^17.0.35",
144
144
  "typescript": "^6.0.3"
145
145
  },
146
146
  "peerDependencies": {
147
- "@gjsify/rolldown-native": "^0.4.25"
147
+ "@gjsify/rolldown-native": "^0.4.27"
148
148
  },
149
149
  "peerDependenciesMeta": {
150
150
  "@gjsify/rolldown-native": {