* chore(npm): rebrand packages to @opengsd scope Rename: - get-shit-done-redux → @opengsd/get-shit-done-redux - @gsd-redux/sdk → @opengsd/gsd-sdk Add publishConfig.access=public for first-time scoped publish. CLI binary names (get-shit-done-redux, gsd-sdk, gsd-tools) unchanged. Sweeps install commands, npx invocations, CI publish/version-check workflows, tests, docs, READMEs (all translations), and the PACKAGE_NAME constant in check-latest-version. Bumps qs 6.15.1 → 6.15.2 to clear a moderate advisory surfaced by the audit-clean test (GHSA-q8mj-m7cp-5q26). Closes #126 * chore: pin 2.0.0 release + remove canary workflow - Bump both packages 1.50.0-canary.0 → 2.0.0 for first @opengsd publish - Remove .github/workflows/canary.yml and canary dist-tag handling in release.yml / release-sdk.yml - Drop canary section from VERSIONING.md Refs #126 * chore: address review findings + harden tarball-smoke timeout - .changeset/opengsd-org-rename.md: match project's custom parse.cjs frontmatter (type: Changed / pr: 127); the scoped @changesets/cli keys were silently rejected. - CONTEXT.md: drop two canary-stream policy lines and a dangling DEFECT.CANARY-VERSION-LEAK.cross-ref now that canary.yml is gone. - tests/release-tarball-smoke.install.test.cjs: pass timeout: 600_000 for npm pack + global install; the 3-minute runNpm default was timing out on slower Docker hosts (cartographer). Refs #126 * fix(sdk): add missing type/runtime devDependencies for build prepublishOnly invokes tsc which couldn't resolve @types/node, @types/ws, or synckit. They had been hoisted from root but were not declared in sdk/'s own package.json — first publish from a clean SDK tree failed. Refs #126 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(ci): use npm pack stdout instead of glob to find tarball `npm pack --silent` for a scoped package (@opengsd/get-shit-done-redux) produces `opengsd-get-shit-done-redux-*.tgz`, not `get-shit-done-redux-*.tgz`. Capture the filename from stdout instead of a hardcoded glob so the step works regardless of package name format. Fixes smoke (ubuntu-latest, 22, false) CI failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * ci: treat workflow-file changes as test-skip eligible `.github/workflows/install-smoke.yml` (and other workflow files) were in neither `test.yml` paths nor `test-skip.yml` paths-ignore, so neither workflow ran on a workflow-only commit — leaving the required test-skip check perpetually missing. Refs #126 * chore: reset version to 1.0.0 for first @opengsd publish Nothing has been published yet under the @opengsd scope, so the inaugural release uses 1.0.0 rather than 2.0.0. The "major bump" in the changeset reflects the breaking install-command change for users migrating from the prior unscoped `get-shit-done-redux`, not a numeric continuation from a 1.x line under the new identity. Refs #126 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
137 lines
4.6 KiB
JavaScript
137 lines
4.6 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* CJS↔SDK Sync Runtime Bridge Adapter — Phase 5/6 of #3524.
|
|
*
|
|
* Single shared loader for the synchronous SDK runtime bridge that every CJS
|
|
* command-router family file and `gsd-tools.cjs` non-family dispatcher
|
|
* delegates through. Centralizing the load prevents the seven-fold duplicated
|
|
* `tryLoadSdk` blocks that existed across the routers from drifting against
|
|
* each other (the exact anti-pattern the Phase 6 hand-sync lint is meant to
|
|
* stop, applied to the SDK-load logic itself).
|
|
*
|
|
* Load path policy: the bridge resolves the bundled SDK by package-relative
|
|
* filesystem path, NOT by the `@opengsd/gsd-sdk` package name. The package name
|
|
* is not installed in the root `node_modules` (it lives as a sibling workspace
|
|
* package, not a dependency), and the SDK's public entry doesn't re-export
|
|
* `executeForCjs` or `formatStateLoadRawStdout` anyway. Using the relative
|
|
* path means the loader works identically in (a) the development checkout
|
|
* (`<repo>/sdk/dist/...`) and (b) the published package layout
|
|
* (`node_modules/get-shit-done-redux/sdk/dist/...`) because the `files` array in
|
|
* `package.json` keeps `sdk/dist` at the same path inside the published
|
|
* tarball.
|
|
*
|
|
* The previous implementation used `require('@opengsd/gsd-sdk')`, which always
|
|
* failed because the package was unresolvable from the consumer location.
|
|
* That cached `_loadFailed = true` for the lifetime of the process and made
|
|
* every router silently fall through to CJS — defeating Phase 5/6's entire
|
|
* goal. The integration test at `tests/cjs-sdk-bridge-integration.test.cjs`
|
|
* locks the load-success invariant so this regression cannot recur.
|
|
*
|
|
* Usage:
|
|
* const { tryLoadSdk, getExecuteForCjs } = require('./cjs-sdk-bridge.cjs');
|
|
* if (tryLoadSdk()) {
|
|
* const result = getExecuteForCjs()({ ... });
|
|
* }
|
|
*
|
|
* Plus `getFormatStateLoadRawStdout()` for the `state load --raw` adapter and
|
|
* `getSdkModule()` for routers that need the raw runtime-bridge-sync module.
|
|
*/
|
|
|
|
const path = require('path');
|
|
|
|
// Computed once at module load. Resolves the bundled SDK relative to this
|
|
// file's on-disk location, so both dev and post-install layouts work.
|
|
// <root>/get-shit-done/bin/lib/cjs-sdk-bridge.cjs
|
|
// <root>/sdk/dist/runtime-bridge-sync/index.js
|
|
// <root>/sdk/dist/query/state-project-load.js
|
|
const RUNTIME_BRIDGE_PATH = path.resolve(
|
|
__dirname,
|
|
'..',
|
|
'..',
|
|
'..',
|
|
'sdk',
|
|
'dist',
|
|
'runtime-bridge-sync',
|
|
'index.js',
|
|
);
|
|
const STATE_PROJECT_LOAD_PATH = path.resolve(
|
|
__dirname,
|
|
'..',
|
|
'..',
|
|
'..',
|
|
'sdk',
|
|
'dist',
|
|
'query',
|
|
'state-project-load.js',
|
|
);
|
|
|
|
let _runtimeBridge = null;
|
|
let _formatStateLoadRawStdout = null;
|
|
let _loadFailed = false;
|
|
|
|
/**
|
|
* Load the bundled SDK runtime bridge once and cache the result. Returns true
|
|
* on success, false if the dist artifacts are missing (e.g. `npm run
|
|
* build:sdk` has not been executed in a fresh dev checkout) or if the
|
|
* expected `executeForCjs` export is absent. Cached result is reused on
|
|
* subsequent calls.
|
|
*/
|
|
function tryLoadSdk() {
|
|
if (_runtimeBridge) return true;
|
|
if (_loadFailed) return false;
|
|
try {
|
|
// eslint-disable-next-line global-require
|
|
const bridge = require(RUNTIME_BRIDGE_PATH);
|
|
if (typeof bridge.executeForCjs !== 'function') {
|
|
_loadFailed = true;
|
|
return false;
|
|
}
|
|
// eslint-disable-next-line global-require
|
|
const stateProjectLoad = require(STATE_PROJECT_LOAD_PATH);
|
|
if (typeof stateProjectLoad.formatStateLoadRawStdout !== 'function') {
|
|
_loadFailed = true;
|
|
return false;
|
|
}
|
|
_runtimeBridge = bridge;
|
|
_formatStateLoadRawStdout = stateProjectLoad.formatStateLoadRawStdout;
|
|
return true;
|
|
} catch {
|
|
_loadFailed = true;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Returns the cached `executeForCjs` function, or null if `tryLoadSdk()` has
|
|
* not been called or returned false. Callers must check `tryLoadSdk()` first.
|
|
*/
|
|
function getExecuteForCjs() {
|
|
return _runtimeBridge ? _runtimeBridge.executeForCjs : null;
|
|
}
|
|
|
|
/**
|
|
* Returns the cached `formatStateLoadRawStdout` function, or null. Used by
|
|
* the state command router for the `state load --raw` adapter that projects
|
|
* SDK return data into the legacy key=value lines format.
|
|
*/
|
|
function getFormatStateLoadRawStdout() {
|
|
return _formatStateLoadRawStdout;
|
|
}
|
|
|
|
/**
|
|
* Returns the cached runtime-bridge-sync module object after a successful
|
|
* `tryLoadSdk()`, or null. Provided for callers that need additional named
|
|
* exports beyond `executeForCjs`.
|
|
*/
|
|
function getSdkModule() {
|
|
return _runtimeBridge;
|
|
}
|
|
|
|
module.exports = {
|
|
tryLoadSdk,
|
|
getExecuteForCjs,
|
|
getFormatStateLoadRawStdout,
|
|
getSdkModule,
|
|
};
|