Skip to content

Commit 46287b4

Browse files
committed
build: update scripts
Formats the release scripts to match the rest of the repo. Also sets `stable` as the first selection in the release script.
1 parent ea4a650 commit 46287b4

File tree

2 files changed

+32
-55
lines changed

2 files changed

+32
-55
lines changed

scripts/npm-publish.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { join } from 'path';
2-
import { spawn } from 'child_process';
3-
import { input, select } from '@inquirer/prompts';
4-
import { executeCommand } from '../runner/utils/exec.js';
5-
import { readFile, writeFile } from 'fs/promises';
1+
import {join} from 'path';
2+
import {spawn} from 'child_process';
3+
import {input, select} from '@inquirer/prompts';
4+
import {executeCommand} from '../runner/utils/exec.js';
5+
import {readFile, writeFile} from 'fs/promises';
66

77
const root = join(import.meta.dirname, '..');
88
const distDirectory = join(root, 'dist');
@@ -22,22 +22,17 @@ const registry = 'https://wombat-dressing-room.appspot.com';
2222

2323
const distTag = await select({
2424
choices: [
25-
{ name: 'Pre-release', value: 'next' },
26-
{ name: 'Stable', value: 'latest' },
25+
{name: 'Stable', value: 'latest'},
26+
{name: 'Pre-release', value: 'next'},
2727
],
2828
message: 'Select a release channel',
2929
});
3030

3131
// Build the project.
32-
await executeCommand(
33-
`pnpm release-build --version=${version}`,
34-
root,
35-
undefined,
36-
{
37-
forwardStdoutToParent: true,
38-
forwardStderrToParent: true,
39-
}
40-
);
32+
await executeCommand(`pnpm release-build --version=${version}`, root, undefined, {
33+
forwardStdoutToParent: true,
34+
forwardStderrToParent: true,
35+
});
4136

4237
// Log into our registry.
4338
await spawnInteractive('npm', ['login', '--registry', registry]);
@@ -50,15 +45,12 @@ const registry = 'https://wombat-dressing-room.appspot.com';
5045
{
5146
forwardStderrToParent: true,
5247
forwardStdoutToParent: true,
53-
}
48+
},
5449
);
5550

5651
// Write the package.json back to disk so the version is in sync.
5752
packageJson.version = version;
58-
await writeFile(
59-
packageJsonPath,
60-
JSON.stringify(packageJson, undefined, 2) + '\n'
61-
);
53+
await writeFile(packageJsonPath, JSON.stringify(packageJson, undefined, 2) + '\n');
6254

6355
console.log('Done! 🎉');
6456
console.log('Remember to push the changed package.json!');
@@ -77,8 +69,6 @@ function spawnInteractive(command: string, args: string[]) {
7769
stdio: 'inherit',
7870
});
7971

80-
childProcess.on('close', (status) =>
81-
status === 0 ? resolve() : reject(status)
82-
);
72+
childProcess.on('close', status => (status === 0 ? resolve() : reject(status)));
8373
});
8474
}

scripts/release-build.ts

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { join } from 'path';
2-
import { rm, cp, readFile, writeFile } from 'fs/promises';
1+
import {join} from 'path';
2+
import {rm, cp, readFile, writeFile} from 'fs/promises';
33
import yargs from 'yargs';
4-
import { hideBin } from 'yargs/helpers';
5-
import { globSync as glob } from 'tinyglobby';
6-
import { executeCommand } from '../runner/utils/exec.js';
4+
import {hideBin} from 'yargs/helpers';
5+
import {globSync as glob} from 'tinyglobby';
6+
import {executeCommand} from '../runner/utils/exec.js';
77

88
const root = join(import.meta.dirname, '..');
99
const runnerSource = join(root, 'runner');
@@ -28,7 +28,7 @@ const args = yargs(hideBin(process.argv))
2828
console.log('Building release output...');
2929

3030
// Clear out the target directory.
31-
await rm(targetDirectory, { recursive: true, force: true });
31+
await rm(targetDirectory, {recursive: true, force: true});
3232

3333
// Build the runner. This also creates `dist`.
3434
await executeCommand('pnpm build-runner', runnerSource, undefined, {
@@ -38,7 +38,7 @@ const args = yargs(hideBin(process.argv))
3838
// Generate the package.json.
3939
await writeFile(
4040
join(targetDirectory, 'package.json'),
41-
await getPackageJson(join(root, 'package.json'), args.version)
41+
await getPackageJson(join(root, 'package.json'), args.version),
4242
);
4343

4444
// Copy the readme and license.
@@ -50,18 +50,10 @@ const args = yargs(hideBin(process.argv))
5050
glob('**/*', {
5151
cwd: join(root, 'examples'),
5252
dot: true,
53-
ignore: [
54-
'**/node_modules/**',
55-
'**/dist/**',
56-
'**/.vinxi/**',
57-
'**/.output/**',
58-
],
59-
}).map((agentFile) =>
60-
cp(
61-
join(root, 'examples', agentFile),
62-
join(targetDirectory, 'examples', agentFile)
63-
)
64-
)
53+
ignore: ['**/node_modules/**', '**/dist/**', '**/.vinxi/**', '**/.output/**'],
54+
}).map(agentFile =>
55+
cp(join(root, 'examples', agentFile), join(targetDirectory, 'examples', agentFile)),
56+
),
6557
);
6658

6759
// The user journey testing requires various files to work.
@@ -71,12 +63,12 @@ const args = yargs(hideBin(process.argv))
7163
cwd: join(root, browserAgentRelativePath),
7264
dot: true,
7365
ignore: ['*.ts', 'README.md'],
74-
}).map((agentFile) =>
66+
}).map(agentFile =>
7567
cp(
7668
join(root, browserAgentRelativePath, agentFile),
77-
join(targetDirectory, browserAgentRelativePath, agentFile)
78-
)
79-
)
69+
join(targetDirectory, browserAgentRelativePath, agentFile),
70+
),
71+
),
8072
);
8173

8274
if (!args.runnerOnly) {
@@ -86,16 +78,13 @@ const args = yargs(hideBin(process.argv))
8678
});
8779

8880
// Copy the report artifacts into the `dist`.
89-
await cp(reportAppDist, targetDirectory, { recursive: true });
81+
await cp(reportAppDist, targetDirectory, {recursive: true});
9082
}
9183

9284
console.log(`Release output has been built in ${targetDirectory}`);
9385
})();
9486

95-
async function getPackageJson(
96-
path: string,
97-
version: string | null
98-
): Promise<string> {
87+
async function getPackageJson(path: string, version: string | null): Promise<string> {
9988
const content = await readFile(path, 'utf8');
10089
const parsed = JSON.parse(content) as {
10190
version: string;
@@ -106,9 +95,7 @@ async function getPackageJson(
10695

10796
if (version) {
10897
if (version === parsed.version) {
109-
throw new Error(
110-
`Specified version is the same version as the current one.`
111-
);
98+
throw new Error(`Specified version is the same version as the current one.`);
11299
} else {
113100
parsed.version = version;
114101
}

0 commit comments

Comments
 (0)