Skip to content

Commit 57f13de

Browse files
author
Ivan Hofer
committed
adapt to svelte setup
1 parent f0e3dc3 commit 57f13de

File tree

8 files changed

+36
-18
lines changed

8 files changed

+36
-18
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
with:
3737
# This expects you to have a script called release which does a build for your packages and calls changeset publish
3838
publish: pnpm release
39-
version: changeset version && node ./packages/kit/scripts/update_version.js
39+
version: pnpm changeset:version
4040
env:
4141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4242
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"lint": "pnpm -r lint && eslint --cache --cache-location node_modules/.eslintcache 'packages/**/*.js'",
1515
"format": "pnpm -r format",
1616
"precommit": "pnpm format && pnpm lint",
17+
"changeset:version": "pnpm -r generate:version && git add --all",
1718
"release": "changeset publish",
1819
"start": "cd sites/kit.svelte.dev && npm run dev"
1920
},

packages/kit/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
"test:cross-platform:build": "pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:build",
6969
"test:unit": "vitest --config kit.vitest.config.js run",
7070
"postinstall": "node postinstall.js",
71-
"prepublishOnly": "node scripts/generate-dts.js"
71+
"prepublishOnly": "node scripts/generate-dts.js",
72+
"generate:version": "node scripts/generate-version.js"
7273
},
7374
"exports": {
7475
"./package.json": "./package.json",
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import fs from 'node:fs';
2+
3+
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
4+
5+
fs.writeFileSync(
6+
'./src/version.js',
7+
`// generated during release, do not modify\n\n/** @type {string} */\nexport const VERSION = '${pkg.version}';\n`
8+
);

packages/kit/scripts/update_version.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

packages/kit/src/exports/public.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type { PluginOptions } from '@sveltejs/vite-plugin-svelte';
2424
export { PrerenderOption } from '../types/private.js';
2525
export { ActionFailure };
2626

27-
export const VERSION: `${number}.${number}.${number}`;
27+
export const VERSION: string;
2828

2929
/**
3030
* [Adapters](https://kit.svelte.dev/docs/adapters) are responsible for taking the production build and turning it into something that can be deployed to a platform of your choosing.

packages/kit/src/version.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
// This file is auto-updated on each release. Please don't edit it manually.
2-
export const VERSION = '1.18.0';
1+
// generated during release, do not modify
2+
3+
/** @type {string} */
4+
export const VERSION = '1.20.4';

packages/kit/src/version.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { fileURLToPath } from 'node:url';
2+
import { readFileSync } from 'node:fs';
3+
import { assert, describe, it } from 'vitest';
4+
import { VERSION } from './version.js';
5+
6+
// runs the version generation as a side-effect of importing
7+
import '../scripts/generate-version.js';
8+
9+
describe('@sveltejs/kit VERSION', () => {
10+
it('should be the exact version from package.json');
11+
const pkg = JSON.parse(
12+
readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf-8')
13+
);
14+
assert.equal(
15+
VERSION,
16+
pkg.version,
17+
'VERSION export in src/version.js does not equal version in package.json'
18+
);
19+
});

0 commit comments

Comments
 (0)