Skip to content
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
"scripts": {
"audit:workflow-permissions": "node scripts/audit-workflow-permissions.mjs",
"build": "tsc -p tsconfig.build.json",
"build": "tsc -p tsconfig.build.json && node -e \"require('node:fs').chmodSync('dist/cli.js', 0o755)\"",
"typecheck": "tsc -p tsconfig.json --noEmit",
"lint": "eslint .",
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"eslint.config.js\" \"vitest.config.ts\" \"package.json\" \"tsconfig*.json\" \".prettierrc\"",
Expand Down
45 changes: 42 additions & 3 deletions scripts/e2e-smoke.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
mkdtempSync,
readFileSync,
rmSync,
statSync,
writeFileSync,
} from 'node:fs';
import { tmpdir } from 'node:os';
Expand All @@ -24,7 +25,7 @@ function runCli(args, cwd, env = process.env) {
env,
encoding: 'utf8',
shell: false,
timeout: 30_000,
timeout: 60_000,
});
}

Expand All @@ -41,6 +42,12 @@ function expectSuccessful(result, label) {
const root = mkdtempSync(join(tmpdir(), 'stellarforge-e2e-'));

try {
assert.match(
readFileSync(cliPath, 'utf8'),
/^#!\/usr\/bin\/env node\r?\n/,
'built CLI must start with the Node shebang',
);

const help = runCli(['--help'], root);
expectSuccessful(help, 'help');
assert.match(help.stdout, /Usage: stellarforge \[options\] \[command\]/);
Expand Down Expand Up @@ -217,10 +224,17 @@ try {
const [packEntry] = JSON.parse(packInspect.stdout);
assert.ok(packEntry, 'pack dry-run returned no entry');
const packedFiles = packEntry.files.map((file) => file.path);
const packedCli = packEntry.files.find((file) => file.path === 'dist/cli.js');
assert.ok(
packedFiles.some((path) => path.startsWith('dist/cli.js')),
packedCli,
'tarball must contain dist/cli.js',
);
if (process.platform !== 'win32') {
assert.ok(
packedCli.mode & 0o111,
'packed dist/cli.js must be executable on POSIX',
);
}
assert.ok(
packedFiles.some((path) => path.startsWith('templates/basic-app/')),
'tarball must contain templates/basic-app/',
Expand Down Expand Up @@ -293,6 +307,20 @@ try {
'@diginodes',
'stellarforge-cli',
);
const installedPackageJson = JSON.parse(
readFileSync(join(installedPackage, 'package.json'), 'utf8'),
);
assert.equal(
installedPackageJson.bin?.stellarforge,
'dist/cli.js',
'packed package bin must point to dist/cli.js',
);
if (process.platform !== 'win32') {
assert.ok(
statSync(join(installedPackage, 'dist', 'cli.js')).mode & 0o111,
'installed dist/cli.js must be executable on POSIX',
);
}
assert.equal(
existsSync(join(installedPackage, 'dist', 'cli.js')),
true,
Expand Down Expand Up @@ -367,5 +395,16 @@ try {
'StellarForge packed tarball consumer smoke test passed.\n',
);
} finally {
rmSync(root, { recursive: true, force: true });
try {
rmSync(root, {
recursive: true,
force: true,
maxRetries: 5,
retryDelay: 100,
});
} catch (error) {
process.stderr.write(
`Warning: could not remove smoke temp directory ${root}: ${error.message}\n`,
);
}
}
Loading