Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/squad-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
],
"scripts": {
"postinstall": "node scripts/patch-esm-imports.mjs && node scripts/patch-ink-rendering.mjs",
"prepack": "npm run build",
"prepublishOnly": "npm run build",
"build": "tsc -p tsconfig.json && npm run postbuild",
"postbuild": "node -e \"require('fs').cpSync('src/remote-ui', 'dist/remote-ui', {recursive: true})\""
Expand Down
1 change: 1 addition & 0 deletions packages/squad-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@
"README.md"
],
"scripts": {
"prepack": "npm run build",
"prepublishOnly": "npm run build",
"build": "tsc -p tsconfig.json"
},
Expand Down
49 changes: 32 additions & 17 deletions test/cli-packaging-smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,38 +27,25 @@ describe('CLI packaging smoke test', { timeout: 120_000 }, () => {
const sdkDir = join(cwd, 'packages', 'squad-sdk');
const cliDir = join(cwd, 'packages', 'squad-cli');

// Build first if dist/ doesn't exist
const sdkDist = join(sdkDir, 'dist');
const cliDist = join(cliDir, 'dist');

// SKIP_BUILD_BUMP prevents bump-build.mjs from mutating versions to
// invalid 4-part semver (e.g. 0.8.25.4) which npm install rejects.
const buildEnv = { ...process.env, SKIP_BUILD_BUMP: '1' };

if (!existsSync(sdkDist)) {
console.log('Building squad-sdk...');
execSync('npm run build', { cwd: sdkDir, stdio: 'inherit', env: buildEnv });
}

if (!existsSync(cliDist)) {
console.log('Building squad-cli...');
execSync('npm run build', { cwd: cliDir, stdio: 'inherit', env: buildEnv });
}

// Pack both packages
// Pack both packages. npm pack must exercise package-local prepack hooks
// so the tarballs always contain fresh dist/ artifacts.
console.log('Packing squad-sdk...');
const sdkPackOutput = execSync('npm pack --quiet', {
cwd: sdkDir,
encoding: 'utf8',
env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0' },
env: { ...buildEnv, NO_COLOR: '1', FORCE_COLOR: '0' },
}).trim();
sdkTarball = join(sdkDir, sdkPackOutput.split('\n').pop()!.trim());

console.log('Packing squad-cli...');
const cliPackOutput = execSync('npm pack --quiet', {
cwd: cliDir,
encoding: 'utf8',
env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0' },
env: { ...buildEnv, NO_COLOR: '1', FORCE_COLOR: '0' },
}).trim();
cliTarball = join(cliDir, cliPackOutput.split('\n').pop()!.trim());

Expand Down Expand Up @@ -210,6 +197,34 @@ describe('CLI packaging smoke test', { timeout: 120_000 }, () => {
expect(pkg.name).toBe('@bradygaster/squad-sdk');
});

it('packaged squad-sdk exports FSStorageProvider from root', () => {
const script = [
"import('@bradygaster/squad-sdk')",
" .then((sdk) => console.log(typeof sdk.FSStorageProvider))",
" .catch((error) => { console.error(error); process.exit(1); });",
].join('');
const stdout = execSync(`node --input-type=module -e ${JSON.stringify(script)}`, {
cwd: tempDir,
encoding: 'utf8',
env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0' },
}).trim();
expect(stdout).toBe('function');
});

it('packaged squad-sdk exports FSStorageProvider from /storage subpath', () => {
const script = [
"import('@bradygaster/squad-sdk/storage')",
" .then((storage) => console.log(typeof storage.FSStorageProvider))",
" .catch((error) => { console.error(error); process.exit(1); });",
].join('');
const stdout = execSync(`node --input-type=module -e ${JSON.stringify(script)}`, {
cwd: tempDir,
encoding: 'utf8',
env: { ...process.env, NO_COLOR: '1', FORCE_COLOR: '0' },
}).trim();
expect(stdout).toBe('function');
});

// ============================================================================
// PHASE 2 — SMOKE TESTS
// ============================================================================
Expand Down
12 changes: 12 additions & 0 deletions test/package-exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ describe('SDK package exports', () => {
expect(typeof sdk.VERSION).toBe('string');
});

it('exports FSStorageProvider from root', async () => {
const sdk = await import('@bradygaster/squad-sdk');
expect(sdk.FSStorageProvider).toBeDefined();
expect(typeof sdk.FSStorageProvider).toBe('function');
});

it('exports from /config subpath', async () => {
const config = await import('@bradygaster/squad-sdk/config');
expect(config).toBeDefined();
Expand Down Expand Up @@ -46,4 +52,10 @@ describe('SDK package exports', () => {
const tools = await import('@bradygaster/squad-sdk/tools');
expect(tools).toBeDefined();
});

it('exports FSStorageProvider from /storage subpath', async () => {
const storage = await import('@bradygaster/squad-sdk/storage');
expect(storage.FSStorageProvider).toBeDefined();
expect(typeof storage.FSStorageProvider).toBe('function');
});
});
Loading