ReviewOS

also looking at this

craft-native/craft

fix(release): build and verify all npm package artifacts

#289
Merged glennmichael123 wants to merge codex/npm-release-artifacts into main
11 files +290 -3

Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.

packages/svelte/README.mdmodified+4-0
Changes to packages/svelte/README.md
@@ -8,6 +8,10 @@ Svelte bindings for the Craft framework using stores and actions.
88npm install @craft-native/svelte
99```
1010
11The package includes its TypeScript source for bundlers that select the `svelte`
12export condition. Other consumers use the compiled ESM or CommonJS entry in
13`dist`. Both entries expose the same stores and actions.
14
1115## Usage
1216
1317### Stores
packages/svelte/package.jsonmodified+2-1
Changes to packages/svelte/package.json
@@ -11,7 +11,8 @@
1111 "url": "https://github.com/craft-native/craft/issues"
1212 },
1313 "files": [
14 "dist"
14 "dist",
15 "src"
1516 ],
1617 "description": "Svelte bindings for Craft framework",
1718 "svelte": "src/index.ts",
scripts/svelte-package.test.tsadded+33-0
Changes to scripts/svelte-package.test.ts
@@ -0,0 +1,33 @@
1import { expect, test } from 'bun:test'
2import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
3import { tmpdir } from 'node:os'
4import { join, resolve } from 'node:path'
5
6test('packed Svelte condition resolves outside the workspace', async () => {
7 const root = resolve(import.meta.dir, '..')
8 const temp = mkdtempSync(join(tmpdir(), 'craft-svelte-package-'))
9 try {
10 const packed = Bun.spawnSync([
11 process.execPath, 'pm', 'pack', '--filename', join(temp, 'package.tgz'),
12 ], { cwd: join(root, 'packages/svelte'), stdout: 'pipe', stderr: 'pipe' })
13 expect(packed.exitCode).toBe(0)
14 const installed = join(temp, 'node_modules/@craft-native/svelte')
15 mkdirSync(installed, { recursive: true })
16 const extracted = Bun.spawnSync([
17 'tar', '-xzf', join(temp, 'package.tgz'), '--strip-components=1', '-C', installed,
18 ], { stdout: 'pipe', stderr: 'pipe' })
19 expect(extracted.exitCode).toBe(0)
20 writeFileSync(join(temp, 'consumer.ts'), "export * from '@craft-native/svelte'\n")
21 const bundled = await Bun.build({
22 entrypoints: [join(temp, 'consumer.ts')],
23 conditions: ['svelte'],
24 external: ['svelte', 'svelte/*', 'craft-native'],
25 target: 'browser',
26 })
27 expect(bundled.logs.filter(log => log.level === 'error')).toEqual([])
28 expect(bundled.success).toBe(true)
29 }
30 finally {
31 rmSync(temp, { recursive: true, force: true })
32 }
33})