@ankhorage/devtools 2.1.1 → 2.1.3

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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  # @ankhorage/devtools
5
5
 
6
- ![license: MIT](././paradox/badges/license.svg) ![npm: v2.1.1](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
6
+ ![license: MIT](././paradox/badges/license.svg) ![npm: v2.1.3](././paradox/badges/npm.svg) ![runtime: bun](././paradox/badges/runtime.svg) ![typescript: strict](././paradox/badges/typescript.svg) ![eslint: checked](././paradox/badges/eslint.svg) ![prettier: checked](././paradox/badges/prettier.svg) ![build: checked](././paradox/badges/build.svg) ![tests: checked](././paradox/badges/tests.svg) ![paradox: warnings](././paradox/badges/docs.svg)
7
7
 
8
8
  Shared tooling, repository automation, and agent standards for Ankhorage TypeScript projects
9
9
 
@@ -99,7 +99,19 @@ jobs:
99
99
  done
100
100
 
101
101
  if [ -n "$release_sha" ]; then
102
- echo "Recovering canonical release commit $release_sha for version $current_version without another version bump."
102
+ release_tag="v$current_version"
103
+ tagged_sha="$(git rev-parse -q --verify "refs/tags/${release_tag}^{commit}" 2>/dev/null || true)"
104
+ if [ -n "$tagged_sha" ] && [ "$tagged_sha" != "$release_sha" ]; then
105
+ echo "::error title=Release tag mismatch::${release_tag} points to ${tagged_sha}, expected ${release_sha}."
106
+ exit 1
107
+ fi
108
+
109
+ if [ -n "$tagged_sha" ]; then
110
+ echo "Release tag ${release_tag} already points to ${release_sha}; resuming idempotent finalization."
111
+ else
112
+ echo "Recovering canonical release commit $release_sha for version $current_version without another version bump."
113
+ fi
114
+ git checkout --detach "$release_sha"
103
115
  echo "versioned=true" >> "$GITHUB_OUTPUT"
104
116
  echo "package_name=$(node -p "require('./package.json').name")" >> "$GITHUB_OUTPUT"
105
117
  echo "package_version=$current_version" >> "$GITHUB_OUTPUT"
@@ -168,9 +180,131 @@ jobs:
168
180
  exit 1
169
181
  fi
170
182
  printf '{"name":"standalone-consumer","private":true,"version":"0.0.0"}\n' > "$install_dir/package.json"
183
+ package_name="$(node -p "require('./package.json').name")"
171
184
  (
172
185
  cd "$install_dir"
173
186
  bun add "$artifact" --ignore-scripts
187
+
188
+ PACKAGE_NAME="$package_name" node - <<'NODE' > runtime-entrypoints.txt
189
+ const { readFileSync } = require('node:fs');
190
+ const { join } = require('node:path');
191
+ const name = process.env.PACKAGE_NAME;
192
+ const packageDir = join(process.cwd(), 'node_modules', ...name.split('/'));
193
+ const pkg = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8'));
194
+ const importConditions = new Set(['bun', 'default', 'import', 'node']);
195
+ const requireConditions = new Set(['default', 'node', 'require']);
196
+ const supportsLoader = (target, conditions) => {
197
+ if (typeof target === 'string') return true;
198
+ if (Array.isArray(target)) return target.some((value) => supportsLoader(value, conditions));
199
+ if (!target || typeof target !== 'object') return false;
200
+ return Object.entries(target).some(
201
+ ([condition, value]) =>
202
+ conditions.has(condition) && supportsLoader(value, conditions),
203
+ );
204
+ };
205
+ const selectLoader = (target) => {
206
+ if (supportsLoader(target, importConditions)) return 'import';
207
+ if (supportsLoader(target, requireConditions)) return 'require';
208
+ return undefined;
209
+ };
210
+ const records = [];
211
+ const addEntrypoint = (specifier, target) => {
212
+ const loader = selectLoader(target);
213
+ if (loader !== undefined) records.push(`${loader}|${specifier}`);
214
+ };
215
+ const exportsMap = pkg.exports;
216
+ if (exportsMap === undefined) {
217
+ if (typeof pkg.main === 'string' || typeof pkg.module === 'string') {
218
+ records.push(`import|${name}`);
219
+ }
220
+ } else if (
221
+ typeof exportsMap === 'string' ||
222
+ Array.isArray(exportsMap) ||
223
+ (exportsMap &&
224
+ typeof exportsMap === 'object' &&
225
+ !Object.keys(exportsMap).some((key) => key.startsWith('.')))
226
+ ) {
227
+ addEntrypoint(name, exportsMap);
228
+ } else if (exportsMap && typeof exportsMap === 'object') {
229
+ for (const [key, target] of Object.entries(exportsMap)) {
230
+ if (!key.startsWith('.') || key === './package.json' || key.includes('*')) continue;
231
+ addEntrypoint(key === '.' ? name : `${name}/${key.slice(2)}`, target);
232
+ }
233
+ }
234
+ const output = records.sort();
235
+ process.stdout.write(output.length === 0 ? '' : `${output.join('\n')}\n`);
236
+ NODE
237
+
238
+ while IFS='|' read -r loader specifier; do
239
+ if [ -z "$specifier" ]; then
240
+ continue
241
+ fi
242
+ case "$loader" in
243
+ import)
244
+ PACKAGE_SPECIFIER="$specifier" bun -e 'await import(process.env.PACKAGE_SPECIFIER)'
245
+ ;;
246
+ require)
247
+ PACKAGE_SPECIFIER="$specifier" node -e 'require(process.env.PACKAGE_SPECIFIER)'
248
+ ;;
249
+ *)
250
+ echo "::error title=Unsupported packed entrypoint loader::Unexpected loader '$loader' for $specifier."
251
+ exit 1
252
+ ;;
253
+ esac
254
+ done < runtime-entrypoints.txt
255
+
256
+ PACKAGE_NAME="$package_name" node - <<'NODE' > binary-paths.txt
257
+ const { readFileSync } = require('node:fs');
258
+ const { join, resolve } = require('node:path');
259
+ const name = process.env.PACKAGE_NAME;
260
+ const packageDir = join(process.cwd(), 'node_modules', ...name.split('/'));
261
+ const pkg = JSON.parse(readFileSync(join(packageDir, 'package.json'), 'utf8'));
262
+ const binaries =
263
+ typeof pkg.bin === 'string'
264
+ ? [pkg.bin]
265
+ : pkg.bin && typeof pkg.bin === 'object'
266
+ ? Object.values(pkg.bin)
267
+ : [];
268
+ const paths = binaries
269
+ .filter((value) => typeof value === 'string')
270
+ .map((value) => resolve(packageDir, value))
271
+ .sort();
272
+ process.stdout.write(paths.length === 0 ? '' : `${paths.join('\n')}\n`);
273
+ NODE
274
+
275
+ while IFS= read -r binary_path; do
276
+ if [ -z "$binary_path" ]; then
277
+ continue
278
+ fi
279
+
280
+ binary_build_dir="$(mktemp -d "${RUNNER_TEMP}/standalone-bin-build.XXXXXX")"
281
+ bun build "$binary_path" --target=bun --outdir "$binary_build_dir" >/dev/null
282
+
283
+ binary_log="$(mktemp "${RUNNER_TEMP}/standalone-bin-smoke.XXXXXX")"
284
+ set +e
285
+ timeout 5s bun "$binary_path" </dev/null >"$binary_log" 2>&1
286
+ binary_status=$?
287
+ set -e
288
+
289
+ if [ "$binary_status" -eq 124 ]; then
290
+ echo "Declared binary $binary_path started successfully and remained active until the smoke timeout."
291
+ continue
292
+ fi
293
+
294
+ if grep -Eiq 'Cannot find (package|module)|ERR_MODULE_NOT_FOUND|MODULE_NOT_FOUND|Could not resolve' "$binary_log"; then
295
+ cat "$binary_log"
296
+ echo "::error title=Packed binary runtime dependency missing::$binary_path could not resolve a runtime dependency."
297
+ exit 1
298
+ fi
299
+
300
+ if [ "$binary_status" -eq 126 ] || [ "$binary_status" -eq 127 ]; then
301
+ cat "$binary_log"
302
+ echo "::error title=Packed binary failed to start::$binary_path exited with status $binary_status."
303
+ exit 1
304
+ fi
305
+
306
+ echo "Declared binary $binary_path started without a missing-runtime-dependency failure (exit $binary_status)."
307
+ done < binary-paths.txt
174
308
  )
175
309
 
176
310
  - name: Publish unpublished packages
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ankhorage/devtools",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "Shared tooling, repository automation, and agent standards for Ankhorage TypeScript projects",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ankhorage/devtools#readme",