-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Expand file tree
/
Copy pathpublish.mjs
More file actions
30 lines (24 loc) · 884 Bytes
/
publish.mjs
File metadata and controls
30 lines (24 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { spawnSync } from 'node:child_process';
import { writeFile } from 'node:fs/promises';
import pkg from '../package.json' with { type: 'json' };
// Strip the devDependencies, since they aren't needed for publish
// Strip the exports, since we don't want to reference './src'
/* eslint-disable @typescript-eslint/no-unused-vars */
const { devDependencies, exports, ...cleanedPkg } = pkg;
// Change `#ui` to `./` from `./src`, since we are publishing
// from the same directory as the source code (rather, the compiled code).
cleanedPkg.imports['#ui/*'] = ['./*'];
await writeFile(
'dist/package.json',
JSON.stringify(cleanedPkg, null, 2),
'utf8'
);
// Now, publish the generated `dist` folder
const { status, error } = spawnSync('pnpm', ['publish', '--no-git-checks'], {
cwd: 'dist',
stdio: 'inherit',
});
if (error) {
throw error;
}
process.exitCode = status;