@sveltejs/kit 1.0.0-next.494 → 1.0.0-next.495

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.494",
3
+ "version": "1.0.0-next.495",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -54,6 +54,7 @@
54
54
  "!src/core/**/test",
55
55
  "types",
56
56
  "svelte-kit.js",
57
+ "postinstall.js",
57
58
  "scripts/special-types"
58
59
  ],
59
60
  "exports": {
@@ -89,6 +90,6 @@
89
90
  "test:integration": "pnpm run -r --workspace-concurrency 1 --filter=\"./test/**\" test",
90
91
  "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\"",
91
92
  "types": "node scripts/extract-types.js",
92
- "postinstall": "node svelte-kit.js sync"
93
+ "postinstall": "node postinstall.js"
93
94
  }
94
95
  }
package/postinstall.js ADDED
@@ -0,0 +1,37 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+ import glob from 'tiny-glob/sync.js';
4
+ import { load_config } from './src/core/config/index.js';
5
+ import * as sync from './src/core/sync/sync.js';
6
+
7
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
8
+
9
+ const directories = [];
10
+
11
+ const cwd = process.env.INIT_CWD ?? process.cwd();
12
+
13
+ if (pkg.workspaces) {
14
+ for (const directory of pkg.workspaces) {
15
+ directories.push(...glob(directory, { cwd }).map((dir) => path.resolve(cwd, dir)));
16
+ }
17
+ } else {
18
+ directories.push(cwd);
19
+ }
20
+
21
+ for (const cwd of directories) {
22
+ process.chdir(cwd);
23
+
24
+ if (!fs.existsSync('package.json')) continue;
25
+ if (!fs.existsSync('svelte.config.js')) continue;
26
+
27
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
28
+ if (!pkg.dependencies?.['@sveltejs/kit'] && !pkg.devDependencies?.['@sveltejs/kit']) continue;
29
+
30
+ try {
31
+ const config = await load_config();
32
+ await sync.all(config, 'development');
33
+ } catch (e) {
34
+ console.log('Error while trying to sync SvelteKit config');
35
+ console.log(e);
36
+ }
37
+ }
package/src/cli.js CHANGED
@@ -41,10 +41,6 @@ prog
41
41
  return;
42
42
  }
43
43
 
44
- if (event === 'postinstall' && process.env.INIT_CWD) {
45
- process.chdir(process.env.INIT_CWD);
46
- }
47
-
48
44
  if (!fs.existsSync('svelte.config.js')) {
49
45
  console.warn(`Missing ${path.resolve('svelte.config.js')} — skipping`);
50
46
  return;