Skip to content

Commit

Permalink
adapt to svelte setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Hofer committed Jun 20, 2023
1 parent f0e3dc3 commit 57f13de
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
version: changeset version && node ./packages/kit/scripts/update_version.js
version: pnpm changeset:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"lint": "pnpm -r lint && eslint --cache --cache-location node_modules/.eslintcache 'packages/**/*.js'",
"format": "pnpm -r format",
"precommit": "pnpm format && pnpm lint",
"changeset:version": "pnpm -r generate:version && git add --all",
"release": "changeset publish",
"start": "cd sites/kit.svelte.dev && npm run dev"
},
Expand Down
3 changes: 2 additions & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
"test:cross-platform:build": "pnpm test:unit && pnpm -r --workspace-concurrency 1 --filter=\"./test/**\" test:cross-platform:build",
"test:unit": "vitest --config kit.vitest.config.js run",
"postinstall": "node postinstall.js",
"prepublishOnly": "node scripts/generate-dts.js"
"prepublishOnly": "node scripts/generate-dts.js",
"generate:version": "node scripts/generate-version.js"
},
"exports": {
"./package.json": "./package.json",
Expand Down
8 changes: 8 additions & 0 deletions packages/kit/scripts/generate-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import fs from 'node:fs';

const pkg = JSON.parse(fs.readFileSync('package.json', 'utf-8'));

fs.writeFileSync(
'./src/version.js',
`// generated during release, do not modify\n\n/** @type {string} */\nexport const VERSION = '${pkg.version}';\n`
);
13 changes: 0 additions & 13 deletions packages/kit/scripts/update_version.js

This file was deleted.

2 changes: 1 addition & 1 deletion packages/kit/src/exports/public.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import type { PluginOptions } from '@sveltejs/vite-plugin-svelte';
export { PrerenderOption } from '../types/private.js';
export { ActionFailure };

export const VERSION: `${number}.${number}.${number}`;
export const VERSION: string;

/**
* [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.
Expand Down
6 changes: 4 additions & 2 deletions packages/kit/src/version.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
// This file is auto-updated on each release. Please don't edit it manually.
export const VERSION = '1.18.0';
// generated during release, do not modify

/** @type {string} */
export const VERSION = '1.20.4';
19 changes: 19 additions & 0 deletions packages/kit/src/version.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { fileURLToPath } from 'node:url';
import { readFileSync } from 'node:fs';
import { assert, describe, it } from 'vitest';
import { VERSION } from './version.js';

// runs the version generation as a side-effect of importing
import '../scripts/generate-version.js';

describe('@sveltejs/kit VERSION', () => {
it('should be the exact version from package.json');
const pkg = JSON.parse(
readFileSync(fileURLToPath(new URL('../package.json', import.meta.url)), 'utf-8')
);
assert.equal(
VERSION,
pkg.version,
'VERSION export in src/version.js does not equal version in package.json'
);
});

0 comments on commit 57f13de

Please sign in to comment.