@sprid/release 1.2.1 → 1.2.2

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/CHANGELOG.md CHANGED
@@ -3,6 +3,11 @@
3
3
  @sprid/release follows semver: a breaking change to a command's arguments, its
4
4
  output shape or its exit codes is a major release.
5
5
 
6
+ ## 1.2.2 - 2026-10-30
7
+
8
+ - Android releases run on Windows: `npx` and Gradle's wrapper start through cmd.exe
9
+ (`gradlew.bat`), with each argument quoted for it.
10
+
6
11
  ## 1.2.1 - 2026-10-08
7
12
 
8
13
  - Republished for the coordinated CLI and screenshot capture update; mobile release behavior remains unchanged.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sprid/release",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Build, sign and release mobile apps locally. Store copy, screenshots, binary uploads and review submissions from one app-owned configuration. Dry run by default.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -4,7 +4,7 @@ import { resolve } from 'node:path';
4
4
  import { releasePath } from '../config.ts';
5
5
  import type { AppReleaseConfig } from '../config.ts';
6
6
  import type { AndroidSigning } from './credentials.ts';
7
- import { run, runLogged } from './exec.ts';
7
+ import { GRADLEW, run, runLogged } from './exec.ts';
8
8
  import { stage, stageLogPath } from '../progress.ts';
9
9
 
10
10
 
@@ -98,13 +98,13 @@ export async function buildAndroid(
98
98
  // with "Timeout waiting to lock journal cache". Cheap; a fresh daemon also
99
99
  // guarantees the jvmargs patched above actually apply.
100
100
  try {
101
- await run('./gradlew', ['--stop'], { cwd: resolve(appDir, 'android'), env });
101
+ await run(GRADLEW, ['--stop'], { cwd: resolve(appDir, 'android'), env });
102
102
  } catch {
103
103
  /* no daemon registry yet — nothing to stop */
104
104
  }
105
105
 
106
106
  await stage('android-build', 'Building Android AAB', () =>
107
- runLogged('./gradlew', ['bundleRelease'], {
107
+ runLogged(GRADLEW, ['bundleRelease'], {
108
108
  cwd: resolve(appDir, 'android'),
109
109
  env,
110
110
  logFile: stageLogPath('android-build', releasePath(config, '.')),
package/src/build/exec.ts CHANGED
@@ -10,6 +10,28 @@ export interface RunOptions {
10
10
  }
11
11
 
12
12
 
13
+ /**
14
+ * Windows starts npm shims and Gradle's wrapper (`npx.cmd`, `gradlew.bat`) only
15
+ * through cmd.exe: Node refuses to spawn a .cmd or .bat file directly. cmd.exe
16
+ * splits the line itself, so each argument is quoted here, and one it cannot
17
+ * carry intact (a double quote, a line break) is refused rather than mangled.
18
+ */
19
+ export function spawnTarget(cmd: string, args: string[], platform: NodeJS.Platform = process.platform): { file: string; args: string[]; shell: boolean } {
20
+ if (platform !== 'win32') return { file: cmd, args, shell: false };
21
+ return { file: [cmd, ...args].map(windowsArg).join(' '), args: [], shell: true };
22
+ }
23
+
24
+ export function windowsArg(arg: string): string {
25
+ if (/^[\w@+=:,./\\-]+$/.test(arg)) return arg;
26
+ if (/["\r\n]/.test(arg)) throw new Error(`Cannot pass ${JSON.stringify(arg)} through cmd.exe on Windows.`);
27
+ // A backslash before the closing quote would escape it: double the run.
28
+ return `"${arg.replace(/(\\+)$/, '$1$1')}"`;
29
+ }
30
+
31
+ /** `./gradlew` on macOS and Linux, the wrapper's batch file on Windows. */
32
+ export const GRADLEW = process.platform === 'win32' ? 'gradlew.bat' : './gradlew';
33
+
34
+
13
35
  const SECRET_FLAGS = new Set(['-P', '-p', '--password', '--apiKey']);
14
36
 
15
37
  const SECRET_KEY = /(password|secret|token|apikey|api_key)/i;
@@ -30,7 +52,8 @@ function redactArgs(args: string[]): string {
30
52
 
31
53
  export function run(cmd: string, args: string[], opts: RunOptions = {}): Promise<void> {
32
54
  return new Promise((resolve, reject) => {
33
- const child = spawn(cmd, args, { stdio: 'inherit', cwd: opts.cwd, env: opts.env ?? process.env });
55
+ const target = spawnTarget(cmd, args);
56
+ const child = spawn(target.file, target.args, { stdio: 'inherit', cwd: opts.cwd, env: opts.env ?? process.env, shell: target.shell });
34
57
  child.on('error', reject);
35
58
  child.on('close', (code) => {
36
59
  if (code === 0) resolve();
@@ -56,7 +79,8 @@ export function runLogged(cmd: string, args: string[], opts: RunLoggedOptions):
56
79
  return new Promise((resolve, reject) => {
57
80
  mkdirSync(dirname(opts.logFile), { recursive: true });
58
81
  const log = createWriteStream(opts.logFile);
59
- const child = spawn(cmd, args, { stdio: ['inherit', 'pipe', 'pipe'], cwd: opts.cwd, env: opts.env ?? process.env });
82
+ const target = spawnTarget(cmd, args);
83
+ const child = spawn(target.file, target.args, { stdio: ['inherit', 'pipe', 'pipe'], cwd: opts.cwd, env: opts.env ?? process.env, shell: target.shell });
60
84
 
61
85
  let pending = '';
62
86
  const consume = (chunk: Buffer) => {
@@ -127,7 +151,8 @@ export function tee(commandLine: string, opts: RunOptions = {}): Promise<{ code:
127
151
 
128
152
  export function capture(cmd: string, args: string[], opts: CaptureOptions = {}): Promise<string> {
129
153
  return new Promise((resolve, reject) => {
130
- const child = spawn(cmd, args, { stdio: ['pipe', 'pipe', 'inherit'], cwd: opts.cwd, env: opts.env ?? process.env });
154
+ const target = spawnTarget(cmd, args);
155
+ const child = spawn(target.file, target.args, { stdio: ['pipe', 'pipe', 'inherit'], cwd: opts.cwd, env: opts.env ?? process.env, shell: target.shell });
131
156
  let out = '';
132
157
  child.stdout.on('data', (d) => (out += d.toString()));
133
158
  child.on('error', reject);