@sveltejs/kit 1.0.0-next.52 → 1.0.0-next.520

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.
Files changed (128) hide show
  1. package/README.md +6 -3
  2. package/package.json +93 -67
  3. package/postinstall.js +47 -0
  4. package/scripts/special-types/$env+dynamic+private.md +10 -0
  5. package/scripts/special-types/$env+dynamic+public.md +8 -0
  6. package/scripts/special-types/$env+static+private.md +19 -0
  7. package/scripts/special-types/$env+static+public.md +7 -0
  8. package/scripts/special-types/$lib.md +5 -0
  9. package/src/cli.js +108 -0
  10. package/src/constants.js +7 -0
  11. package/src/core/adapt/builder.js +215 -0
  12. package/src/core/adapt/index.js +31 -0
  13. package/src/core/config/default-error.html +56 -0
  14. package/src/core/config/index.js +110 -0
  15. package/src/core/config/options.js +504 -0
  16. package/src/core/config/types.d.ts +1 -0
  17. package/src/core/env.js +121 -0
  18. package/src/core/generate_manifest/index.js +94 -0
  19. package/src/core/prerender/crawl.js +198 -0
  20. package/src/core/prerender/entities.js +2252 -0
  21. package/src/core/prerender/prerender.js +458 -0
  22. package/src/core/prerender/queue.js +80 -0
  23. package/src/core/sync/create_manifest_data/conflict.js +0 -0
  24. package/src/core/sync/create_manifest_data/index.js +470 -0
  25. package/src/core/sync/create_manifest_data/sort.js +163 -0
  26. package/src/core/sync/create_manifest_data/types.d.ts +37 -0
  27. package/src/core/sync/sync.js +78 -0
  28. package/src/core/sync/utils.js +33 -0
  29. package/src/core/sync/write_ambient.js +53 -0
  30. package/src/core/sync/write_client_manifest.js +106 -0
  31. package/src/core/sync/write_matchers.js +25 -0
  32. package/src/core/sync/write_root.js +91 -0
  33. package/src/core/sync/write_tsconfig.js +195 -0
  34. package/src/core/sync/write_types/index.js +783 -0
  35. package/src/core/utils.js +70 -0
  36. package/src/exports/hooks/index.js +1 -0
  37. package/src/exports/hooks/sequence.js +44 -0
  38. package/src/exports/index.js +45 -0
  39. package/src/exports/node/index.js +161 -0
  40. package/src/exports/node/polyfills.js +28 -0
  41. package/src/exports/vite/build/build_server.js +378 -0
  42. package/src/exports/vite/build/build_service_worker.js +91 -0
  43. package/src/exports/vite/build/utils.js +181 -0
  44. package/src/exports/vite/dev/index.js +581 -0
  45. package/src/exports/vite/graph_analysis/index.js +277 -0
  46. package/src/exports/vite/graph_analysis/types.d.ts +5 -0
  47. package/src/exports/vite/graph_analysis/utils.js +30 -0
  48. package/src/exports/vite/index.js +603 -0
  49. package/src/exports/vite/preview/index.js +189 -0
  50. package/src/exports/vite/types.d.ts +3 -0
  51. package/src/exports/vite/utils.js +157 -0
  52. package/src/runtime/app/env.js +1 -0
  53. package/src/runtime/app/environment.js +11 -0
  54. package/src/runtime/app/forms.js +123 -0
  55. package/src/runtime/app/navigation.js +23 -0
  56. package/src/runtime/app/paths.js +1 -0
  57. package/src/runtime/app/stores.js +102 -0
  58. package/src/runtime/client/ambient.d.ts +30 -0
  59. package/src/runtime/client/client.js +1595 -0
  60. package/src/runtime/client/fetcher.js +107 -0
  61. package/src/runtime/client/parse.js +60 -0
  62. package/src/runtime/client/singletons.js +21 -0
  63. package/src/runtime/client/start.js +37 -0
  64. package/src/runtime/client/types.d.ts +84 -0
  65. package/src/runtime/client/utils.js +159 -0
  66. package/src/runtime/components/error.svelte +16 -0
  67. package/{assets → src/runtime}/components/layout.svelte +0 -0
  68. package/src/runtime/control.js +98 -0
  69. package/src/runtime/env/dynamic/private.js +1 -0
  70. package/src/runtime/env/dynamic/public.js +1 -0
  71. package/src/runtime/env-private.js +6 -0
  72. package/src/runtime/env-public.js +6 -0
  73. package/src/runtime/env.js +6 -0
  74. package/src/runtime/hash.js +20 -0
  75. package/src/runtime/paths.js +11 -0
  76. package/src/runtime/server/cookie.js +166 -0
  77. package/src/runtime/server/data/index.js +131 -0
  78. package/src/runtime/server/endpoint.js +92 -0
  79. package/src/runtime/server/fetch.js +174 -0
  80. package/src/runtime/server/index.js +355 -0
  81. package/src/runtime/server/page/actions.js +256 -0
  82. package/src/runtime/server/page/crypto.js +239 -0
  83. package/src/runtime/server/page/csp.js +250 -0
  84. package/src/runtime/server/page/index.js +304 -0
  85. package/src/runtime/server/page/load_data.js +215 -0
  86. package/src/runtime/server/page/render.js +346 -0
  87. package/src/runtime/server/page/respond_with_error.js +102 -0
  88. package/src/runtime/server/page/serialize_data.js +87 -0
  89. package/src/runtime/server/page/types.d.ts +35 -0
  90. package/src/runtime/server/utils.js +181 -0
  91. package/src/utils/array.js +9 -0
  92. package/src/utils/error.js +22 -0
  93. package/src/utils/escape.js +46 -0
  94. package/src/utils/filesystem.js +142 -0
  95. package/src/utils/functions.js +16 -0
  96. package/src/utils/http.js +72 -0
  97. package/src/utils/misc.js +1 -0
  98. package/src/utils/promises.js +17 -0
  99. package/src/utils/routing.js +130 -0
  100. package/src/utils/unit_test.js +11 -0
  101. package/src/utils/url.js +144 -0
  102. package/svelte-kit.js +1 -1
  103. package/types/ambient.d.ts +431 -0
  104. package/types/index.d.ts +477 -0
  105. package/types/internal.d.ts +380 -0
  106. package/types/private.d.ts +224 -0
  107. package/CHANGELOG.md +0 -496
  108. package/assets/components/error.svelte +0 -13
  109. package/assets/runtime/app/env.js +0 -5
  110. package/assets/runtime/app/navigation.js +0 -44
  111. package/assets/runtime/app/paths.js +0 -1
  112. package/assets/runtime/app/stores.js +0 -93
  113. package/assets/runtime/chunks/utils.js +0 -22
  114. package/assets/runtime/internal/singletons.js +0 -23
  115. package/assets/runtime/internal/start.js +0 -776
  116. package/assets/runtime/paths.js +0 -12
  117. package/dist/chunks/index.js +0 -3537
  118. package/dist/chunks/index2.js +0 -587
  119. package/dist/chunks/index3.js +0 -246
  120. package/dist/chunks/index4.js +0 -568
  121. package/dist/chunks/index5.js +0 -763
  122. package/dist/chunks/index6.js +0 -323
  123. package/dist/chunks/standard.js +0 -99
  124. package/dist/chunks/utils.js +0 -83
  125. package/dist/cli.js +0 -555
  126. package/dist/ssr.js +0 -2604
  127. package/types.d.ts +0 -73
  128. package/types.internal.d.ts +0 -222
package/dist/cli.js DELETED
@@ -1,555 +0,0 @@
1
- import { existsSync } from 'fs';
2
- import sade from 'sade';
3
- import { pathToFileURL, resolve as resolve$1 } from 'url';
4
- import path from 'path';
5
-
6
- let FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, isTTY=true;
7
- if (typeof process !== 'undefined') {
8
- ({ FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM } = process.env);
9
- isTTY = process.stdout && process.stdout.isTTY;
10
- }
11
-
12
- const $ = {
13
- enabled: !NODE_DISABLE_COLORS && NO_COLOR == null && TERM !== 'dumb' && (
14
- FORCE_COLOR != null && FORCE_COLOR !== '0' || isTTY
15
- ),
16
-
17
- // modifiers
18
- reset: init(0, 0),
19
- bold: init(1, 22),
20
- dim: init(2, 22),
21
- italic: init(3, 23),
22
- underline: init(4, 24),
23
- inverse: init(7, 27),
24
- hidden: init(8, 28),
25
- strikethrough: init(9, 29),
26
-
27
- // colors
28
- black: init(30, 39),
29
- red: init(31, 39),
30
- green: init(32, 39),
31
- yellow: init(33, 39),
32
- blue: init(34, 39),
33
- magenta: init(35, 39),
34
- cyan: init(36, 39),
35
- white: init(37, 39),
36
- gray: init(90, 39),
37
- grey: init(90, 39),
38
-
39
- // background colors
40
- bgBlack: init(40, 49),
41
- bgRed: init(41, 49),
42
- bgGreen: init(42, 49),
43
- bgYellow: init(43, 49),
44
- bgBlue: init(44, 49),
45
- bgMagenta: init(45, 49),
46
- bgCyan: init(46, 49),
47
- bgWhite: init(47, 49)
48
- };
49
-
50
- function run(arr, str) {
51
- let i=0, tmp, beg='', end='';
52
- for (; i < arr.length; i++) {
53
- tmp = arr[i];
54
- beg += tmp.open;
55
- end += tmp.close;
56
- if (!!~str.indexOf(tmp.close)) {
57
- str = str.replace(tmp.rgx, tmp.close + tmp.open);
58
- }
59
- }
60
- return beg + str + end;
61
- }
62
-
63
- function chain(has, keys) {
64
- let ctx = { has, keys };
65
-
66
- ctx.reset = $.reset.bind(ctx);
67
- ctx.bold = $.bold.bind(ctx);
68
- ctx.dim = $.dim.bind(ctx);
69
- ctx.italic = $.italic.bind(ctx);
70
- ctx.underline = $.underline.bind(ctx);
71
- ctx.inverse = $.inverse.bind(ctx);
72
- ctx.hidden = $.hidden.bind(ctx);
73
- ctx.strikethrough = $.strikethrough.bind(ctx);
74
-
75
- ctx.black = $.black.bind(ctx);
76
- ctx.red = $.red.bind(ctx);
77
- ctx.green = $.green.bind(ctx);
78
- ctx.yellow = $.yellow.bind(ctx);
79
- ctx.blue = $.blue.bind(ctx);
80
- ctx.magenta = $.magenta.bind(ctx);
81
- ctx.cyan = $.cyan.bind(ctx);
82
- ctx.white = $.white.bind(ctx);
83
- ctx.gray = $.gray.bind(ctx);
84
- ctx.grey = $.grey.bind(ctx);
85
-
86
- ctx.bgBlack = $.bgBlack.bind(ctx);
87
- ctx.bgRed = $.bgRed.bind(ctx);
88
- ctx.bgGreen = $.bgGreen.bind(ctx);
89
- ctx.bgYellow = $.bgYellow.bind(ctx);
90
- ctx.bgBlue = $.bgBlue.bind(ctx);
91
- ctx.bgMagenta = $.bgMagenta.bind(ctx);
92
- ctx.bgCyan = $.bgCyan.bind(ctx);
93
- ctx.bgWhite = $.bgWhite.bind(ctx);
94
-
95
- return ctx;
96
- }
97
-
98
- function init(open, close) {
99
- let blk = {
100
- open: `\x1b[${open}m`,
101
- close: `\x1b[${close}m`,
102
- rgx: new RegExp(`\\x1b\\[${close}m`, 'g')
103
- };
104
- return function (txt) {
105
- if (this !== void 0 && this.has !== void 0) {
106
- !!~this.has.indexOf(open) || (this.has.push(open),this.keys.push(blk));
107
- return txt === void 0 ? this : $.enabled ? run(this.keys, txt+'') : txt+'';
108
- }
109
- return txt === void 0 ? chain([open], [blk]) : $.enabled ? run([blk], txt+'') : txt+'';
110
- };
111
- }
112
-
113
- const noop = () => {};
114
-
115
- /** @typedef {import('./types').ConfigDefinition} ConfigDefinition */
116
-
117
- /** @type {Record<string, ConfigDefinition>} */
118
- const options = {
119
- compilerOptions: {
120
- type: 'leaf',
121
- default: null,
122
- validate: noop
123
- },
124
-
125
- extensions: {
126
- type: 'leaf',
127
- default: ['.svelte'],
128
- validate: (option, keypath) => {
129
- if (!Array.isArray(option) || !option.every((page) => typeof page === 'string')) {
130
- throw new Error(`${keypath} must be an array of strings`);
131
- }
132
-
133
- option.forEach((extension) => {
134
- if (extension[0] !== '.') {
135
- throw new Error(`Each member of ${keypath} must start with '.' — saw '${extension}'`);
136
- }
137
-
138
- if (!/^(\.[a-z0-9]+)+$/i.test(extension)) {
139
- throw new Error(`File extensions must be alphanumeric — saw '${extension}'`);
140
- }
141
- });
142
-
143
- return option;
144
- }
145
- },
146
-
147
- kit: {
148
- type: 'branch',
149
- children: {
150
- adapter: {
151
- type: 'leaf',
152
- default: [null],
153
- validate: (option, keypath) => {
154
- // support both `adapter: 'foo'` and `adapter: ['foo', opts]`
155
- if (!Array.isArray(option)) {
156
- option = [option];
157
- }
158
-
159
- // TODO allow inline functions
160
- assert_is_string(option[0], keypath);
161
-
162
- return option;
163
- }
164
- },
165
-
166
- amp: expect_boolean(false),
167
-
168
- appDir: expect_string('_app', false),
169
-
170
- files: {
171
- type: 'branch',
172
- children: {
173
- assets: expect_string('static'),
174
- lib: expect_string('src/lib'),
175
- routes: expect_string('src/routes'),
176
- serviceWorker: expect_string('src/service-worker'),
177
- setup: expect_string('src/setup'),
178
- template: expect_string('src/app.html')
179
- }
180
- },
181
-
182
- host: expect_string(null),
183
-
184
- hostHeader: expect_string(null),
185
-
186
- paths: {
187
- type: 'branch',
188
- children: {
189
- base: expect_string(''),
190
- assets: expect_string('')
191
- }
192
- },
193
-
194
- prerender: {
195
- type: 'branch',
196
- children: {
197
- crawl: expect_boolean(true),
198
- enabled: expect_boolean(true),
199
- force: expect_boolean(false),
200
- pages: {
201
- type: 'leaf',
202
- default: ['*'],
203
- validate: (option, keypath) => {
204
- if (!Array.isArray(option) || !option.every((page) => typeof page === 'string')) {
205
- throw new Error(`${keypath} must be an array of strings`);
206
- }
207
-
208
- option.forEach((page) => {
209
- if (page !== '*' && page[0] !== '/') {
210
- throw new Error(
211
- `Each member of ${keypath} must be either '*' or an absolute path beginning with '/' — saw '${page}'`
212
- );
213
- }
214
- });
215
-
216
- return option;
217
- }
218
- }
219
- }
220
- },
221
-
222
- target: expect_string(null),
223
-
224
- vite: {
225
- type: 'leaf',
226
- default: () => ({}),
227
- validate: (option, keypath) => {
228
- if (typeof option === 'object') {
229
- const config = option;
230
- option = () => config;
231
- }
232
-
233
- if (typeof option !== 'function') {
234
- throw new Error(
235
- `${keypath} must be a Vite config object (https://vitejs.dev/config) or a function that returns one`
236
- );
237
- }
238
-
239
- return option;
240
- }
241
- }
242
- }
243
- },
244
-
245
- preprocess: {
246
- type: 'leaf',
247
- default: null,
248
- validate: noop
249
- }
250
- };
251
-
252
- /**
253
- * @param {string} string
254
- * @param {boolean} allow_empty
255
- * @returns {ConfigDefinition}
256
- */
257
- function expect_string(string, allow_empty = true) {
258
- return {
259
- type: 'leaf',
260
- default: string,
261
- validate: (option, keypath) => {
262
- assert_is_string(option, keypath);
263
- if (!allow_empty && option === '') {
264
- throw new Error(`${keypath} cannot be empty`);
265
- }
266
- return option;
267
- }
268
- };
269
- }
270
-
271
- /**
272
- * @param {boolean} boolean
273
- * @returns {ConfigDefinition}
274
- */
275
- function expect_boolean(boolean) {
276
- return {
277
- type: 'leaf',
278
- default: boolean,
279
- validate: (option, keypath) => {
280
- if (typeof option !== 'boolean') {
281
- throw new Error(`${keypath} should be true or false, if specified`);
282
- }
283
- return option;
284
- }
285
- };
286
- }
287
-
288
- /**
289
- * @param {any} option
290
- * @param {string} keypath
291
- */
292
- function assert_is_string(option, keypath) {
293
- if (typeof option !== 'string') {
294
- throw new Error(`${keypath} should be a string, if specified`);
295
- }
296
- }
297
-
298
- /** @typedef {import('./types').ConfigDefinition} ConfigDefinition */
299
-
300
- /**
301
- * @param {Record<string, ConfigDefinition>} definition
302
- * @param {any} option
303
- * @param {string} keypath
304
- * @returns {any}
305
- */
306
- function validate(definition, option, keypath) {
307
- for (const key in option) {
308
- if (!(key in definition)) {
309
- let message = `Unexpected option ${keypath}.${key}`;
310
-
311
- if (keypath === 'config' && key in options.kit) {
312
- message += ` (did you mean config.kit.${key}?)`;
313
- } else if (keypath === 'config.kit' && key in options) {
314
- message += ` (did you mean config.${key}?)`;
315
- }
316
-
317
- throw new Error(message);
318
- }
319
- }
320
-
321
- /** @type {Record<string, any>} */
322
- const merged = {};
323
-
324
- for (const key in definition) {
325
- const expected = definition[key];
326
- const actual = option[key];
327
-
328
- const child_keypath = `${keypath}.${key}`;
329
-
330
- if (key in option) {
331
- if (expected.type === 'branch') {
332
- if (actual && (typeof actual !== 'object' || Array.isArray(actual))) {
333
- throw new Error(`${keypath}.${key} should be an object`);
334
- }
335
-
336
- merged[key] = validate(expected.children, actual, child_keypath);
337
- } else {
338
- merged[key] = expected.validate(actual, child_keypath);
339
- }
340
- } else {
341
- merged[key] =
342
- expected.type === 'branch'
343
- ? validate(expected.children, {}, child_keypath)
344
- : expected.default;
345
- }
346
- }
347
-
348
- return merged;
349
- }
350
-
351
- /**
352
- * @param {string} from
353
- * @param {string} to
354
- */
355
- function resolve(from, to) {
356
- // the `/.` is weird, but allows `${assets}/images/blah.jpg` to work
357
- // when `assets` is empty
358
- return remove_trailing_slash(resolve$1(add_trailing_slash(from), to)) || '/.';
359
- }
360
-
361
- /**
362
- * @param {string} str
363
- */
364
- function add_trailing_slash(str) {
365
- return str.endsWith('/') ? str : `${str}/`;
366
- }
367
-
368
- /**
369
- * @param {string} str
370
- */
371
- function remove_trailing_slash(str) {
372
- return str.endsWith('/') ? str.slice(0, -1) : str;
373
- }
374
-
375
- async function load_config({ cwd = process.cwd() } = {}) {
376
- const config_file = path.join(cwd, 'svelte.config.cjs');
377
- const config = await import(pathToFileURL(config_file).href);
378
- const validated = validate_config(config.default);
379
-
380
- validated.kit.files.assets = path.resolve(cwd, validated.kit.files.assets);
381
- validated.kit.files.lib = path.resolve(cwd, validated.kit.files.lib);
382
- validated.kit.files.routes = path.resolve(cwd, validated.kit.files.routes);
383
- validated.kit.files.serviceWorker = path.resolve(cwd, validated.kit.files.serviceWorker);
384
- validated.kit.files.setup = path.resolve(cwd, validated.kit.files.setup);
385
- validated.kit.files.template = path.resolve(cwd, validated.kit.files.template);
386
-
387
- // TODO check all the `files` exist when the config is loaded?
388
- // TODO check that `target` is present in the provided template
389
-
390
- return validated;
391
- }
392
-
393
- /**
394
- * @param {import('../../../types').Config} config
395
- * @returns {import('../../../types.internal.js').ValidatedConfig}
396
- */
397
- function validate_config(config) {
398
- /** @type {import('../../../types.internal.js').ValidatedConfig} */
399
- const validated = validate(options, config, 'config');
400
-
401
- // resolve paths
402
- const { paths } = validated.kit;
403
-
404
- if (paths.base !== '' && !paths.base.startsWith('/')) {
405
- throw new Error('config.kit.paths.base must be a root-relative path');
406
- }
407
-
408
- paths.assets = resolve(paths.base, paths.assets);
409
-
410
- return validated;
411
- }
412
-
413
- async function get_config() {
414
- // TODO this is temporary, for the benefit of early adopters
415
- if (existsSync('snowpack.config.js') || existsSync('snowpack.config.cjs')) {
416
- // prettier-ignore
417
- console.error($.bold().red(
418
- 'SvelteKit now uses https://vitejs.dev. Please remove snowpack.config.js and put Vite config in svelte.config.cjs: https://kit.svelte.dev/docs#configuration-vite'
419
- ));
420
- } else if (existsSync('vite.config.js')) {
421
- // prettier-ignore
422
- console.error($.bold().red(
423
- 'Please remove vite.config.js and put Vite config in svelte.config.cjs: https://kit.svelte.dev/docs#configuration-vite'
424
- ));
425
- }
426
-
427
- try {
428
- return await load_config();
429
- } catch (error) {
430
- let message = error.message;
431
-
432
- if (error.code === 'MODULE_NOT_FOUND') {
433
- if (existsSync('svelte.config.js')) {
434
- // TODO this is temporary, for the benefit of early adopters
435
- message = 'You must rename svelte.config.js to svelte.config.cjs';
436
- } else {
437
- message = 'Missing svelte.config.cjs';
438
- }
439
- } else if (error.name === 'SyntaxError') {
440
- message = 'Malformed svelte.config.cjs';
441
- }
442
-
443
- console.error($.bold().red(message));
444
- console.error($.grey(error.stack));
445
- process.exit(1);
446
- }
447
- }
448
-
449
- /** @param {Error} error */
450
- function handle_error(error) {
451
- console.log($.bold().red(`> ${error.message}`));
452
- console.log($.gray(error.stack));
453
- process.exit(1);
454
- }
455
-
456
- /** @param {number} port */
457
- async function launch(port) {
458
- const { exec } = await import('child_process');
459
- exec(`${process.platform == 'win32' ? 'start' : 'open'} http://localhost:${port}`);
460
- }
461
-
462
- const prog = sade('svelte-kit').version('1.0.0-next.52');
463
-
464
- prog
465
- .command('dev')
466
- .describe('Start a development server')
467
- .option('-p, --port', 'Port', 3000)
468
- .option('-o, --open', 'Open a browser tab', false)
469
- .action(async ({ port, open }) => {
470
- process.env.NODE_ENV = 'development';
471
- const config = await get_config();
472
-
473
- const { dev } = await import('./chunks/index.js');
474
-
475
- try {
476
- const watcher = await dev({ port, config });
477
-
478
- watcher.on('stdout', (data) => {
479
- process.stdout.write(data);
480
- });
481
-
482
- watcher.on('stderr', (data) => {
483
- process.stderr.write(data);
484
- });
485
-
486
- console.log($.bold().cyan(`> Listening on http://localhost:${watcher.port}`));
487
- if (open) launch(watcher.port);
488
- } catch (error) {
489
- handle_error(error);
490
- }
491
- });
492
-
493
- prog
494
- .command('build')
495
- .describe('Create a production build of your app')
496
- .option('--verbose', 'Log more stuff', false)
497
- .action(async ({ verbose }) => {
498
- process.env.NODE_ENV = 'production';
499
- const config = await get_config();
500
-
501
- try {
502
- const { build } = await import('./chunks/index4.js');
503
- await build(config);
504
-
505
- console.log(`\nRun ${$.bold().cyan('npm start')} to try your app locally.`);
506
-
507
- if (config.kit.adapter[0]) {
508
- const { adapt } = await import('./chunks/index5.js');
509
- await adapt(config, { verbose });
510
- } else {
511
- console.log($.bold().yellow('\nNo adapter specified'));
512
-
513
- // prettier-ignore
514
- console.log(
515
- `See ${$.bold().cyan('https://kit.svelte.dev/docs#adapters')} to learn how to configure your app to run on the platform of your choosing`
516
- );
517
- }
518
- } catch (error) {
519
- handle_error(error);
520
- }
521
- });
522
-
523
- prog
524
- .command('start')
525
- .describe('Serve an already-built app')
526
- .option('-p, --port', 'Port', 3000)
527
- .option('-o, --open', 'Open a browser tab', false)
528
- .action(async ({ port, open }) => {
529
- process.env.NODE_ENV = 'production';
530
- const config = await get_config();
531
-
532
- const { start } = await import('./chunks/index6.js');
533
-
534
- try {
535
- await start({ port, config });
536
-
537
- console.log($.bold().cyan(`> Listening on http://localhost:${port}`));
538
- if (open) if (open) launch(port);
539
- } catch (error) {
540
- handle_error(error);
541
- }
542
- });
543
-
544
- // For the benefit of early-adopters. Can later be removed
545
- prog
546
- .command('adapt')
547
- .describe('Customise your production build for different platforms')
548
- .option('--verbose', 'Log more stuff', false)
549
- .action(async () => {
550
- console.log('"svelte-kit build" will now run the adapter');
551
- });
552
-
553
- prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });
554
-
555
- export { $ };