@sveltejs/kit 1.0.0-next.398 → 1.0.0-next.399

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/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import fs__default from 'fs';
2
+ import path__default from 'path';
2
3
  import { l as load_config, $ } from './chunks/index.js';
3
4
  import sade from 'sade';
4
5
  import { c as coalesce_to_error } from './chunks/error.js';
5
- import 'path';
6
6
  import 'url';
7
7
 
8
8
  /** @param {unknown} e */
@@ -19,7 +19,7 @@ function handle_error(e) {
19
19
  process.exit(1);
20
20
  }
21
21
 
22
- const prog = sade('svelte-kit').version('1.0.0-next.398');
22
+ const prog = sade('svelte-kit').version('1.0.0-next.399');
23
23
 
24
24
  prog
25
25
  .command('package')
@@ -41,13 +41,30 @@ prog
41
41
  .describe('Synchronise generated files')
42
42
  .option('--mode', 'Specify a mode for loading environment variables', 'development')
43
43
  .action(async ({ mode }) => {
44
- if (!fs__default.existsSync('svelte.config.js')) {
45
- console.warn('Missing svelte.config.js — skipping');
44
+ const event = process.env.npm_lifecycle_event;
45
+
46
+ // TODO remove for 1.0
47
+ if (event === 'prepare') {
48
+ const pkg = JSON.parse(fs__default.readFileSync('package.json', 'utf8'));
49
+ const message =
50
+ pkg.scripts.prepare === 'svelte-kit sync'
51
+ ? `\`svelte-kit sync\` now runs on "postinstall" — please remove the "prepare" script from your package.json\n`
52
+ : `\`svelte-kit sync\` now runs on "postinstall" — please remove it from your "prepare" script\n`;
53
+
54
+ console.error($.bold().red(message));
55
+ return;
56
+ }
57
+
58
+ const cwd = event === 'postinstall' ? process.env.INIT_CWD ?? '' : process.cwd();
59
+
60
+ const svelte_config_file = path__default.join(cwd, 'svelte.config.js');
61
+ if (!fs__default.existsSync(svelte_config_file)) {
62
+ console.warn(`Missing ${svelte_config_file} — skipping`);
46
63
  return;
47
64
  }
48
65
 
49
66
  try {
50
- const config = await load_config();
67
+ const config = await load_config({ cwd });
51
68
  const sync = await import('./chunks/sync.js').then(function (n) { return n.f; });
52
69
  sync.all(config, mode);
53
70
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/kit",
3
- "version": "1.0.0-next.398",
3
+ "version": "1.0.0-next.399",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -20,7 +20,7 @@
20
20
  "@types/connect": "^3.4.35",
21
21
  "@types/cookie": "^0.5.1",
22
22
  "@types/marked": "^4.0.3",
23
- "@types/mime": "^2.0.3",
23
+ "@types/mime": "^3.0.0",
24
24
  "@types/node": "^16.11.36",
25
25
  "@types/sade": "^1.7.4",
26
26
  "@types/set-cookie-parser": "^2.4.2",
@@ -93,6 +93,7 @@
93
93
  "test:unit": "uvu src \"(spec\\.js|test[\\\\/]index\\.js)\" -i packaging",
94
94
  "test:typings": "tsc --project test/typings",
95
95
  "test:packaging": "uvu src/packaging \"(spec\\.js|test[\\\\/]index\\.js)\"",
96
- "types": "node scripts/extract-types.js"
96
+ "types": "node scripts/extract-types.js",
97
+ "postinstall": "node svelte-kit.js sync"
97
98
  }
98
99
  }
package/svelte-kit.js CHANGED
@@ -1,2 +1,11 @@
1
1
  #!/usr/bin/env node
2
- import './dist/cli.js';
2
+ import fs from 'fs';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ // in our own CI, and when deploying directly from this monorepo,
6
+ // the `dist` directory will not exist yet
7
+ if (fs.existsSync(fileURLToPath(new URL('./dist', import.meta.url)))) {
8
+ import('./dist/cli.js');
9
+ } else {
10
+ console.error('Run "pnpm build" and try running this command again');
11
+ }