Skip to content

Commit

Permalink
Merge branch 'master' into gh-4112
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris authored Mar 3, 2022
2 parents da081a6 + 255e0d2 commit 9545b8b
Show file tree
Hide file tree
Showing 106 changed files with 357 additions and 325 deletions.
6 changes: 6 additions & 0 deletions .changeset/five-poems-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'create-svelte': patch
'@sveltejs/kit': patch
---

Add sync CLI command
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
run: find packages -type d -name test-results -not -empty | tar -czf test-results.tar.gz --exclude='*-retry*' --files-from=-
- name: Upload failed tests screenshots
if: failure()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
retention-days: 3
name: test-failure-${{ github.run_id }}-${{ matrix.os }}-${{ matrix.node-version }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"package": "svelte-kit package",
"preview": "svelte-kit preview"
"preview": "svelte-kit preview",
"prepare": "svelte-kit sync"
},
"devDependencies": {
"@sveltejs/adapter-auto": "next",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"package": "svelte-kit package",
"preview": "svelte-kit preview"
"preview": "svelte-kit preview",
"prepare": "svelte-kit sync"
},
"devDependencies": {
"@sveltejs/adapter-auto": "workspace:*",
Expand Down
13 changes: 13 additions & 0 deletions packages/kit/src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ prog
}
});

prog
.command('sync')
.describe('Synchronise generated files')
.action(async () => {
try {
const config = await load_config();
const sync = await import('./core/sync/sync.js');
sync.all(config);
} catch (error) {
handle_error(error);
}
});

prog.parse(process.argv, { unknown: (arg) => `Unknown option: ${arg}` });

/** @param {number} port */
Expand Down
11 changes: 1 addition & 10 deletions packages/kit/src/core/build/build_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import path from 'path';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import { deep_merge } from '../../utils/object.js';
import { print_config_conflicts } from '../config/index.js';
import { create_app } from '../create_app/index.js';
import { copy_assets, get_aliases } from '../utils.js';
import { get_aliases } from '../utils.js';
import { create_build, find_deps } from './utils.js';
import { posixify } from '../../utils/filesystem.js';

Expand Down Expand Up @@ -32,14 +31,6 @@ export async function build_client({
process.env.VITE_SVELTEKIT_APP_VERSION_FILE = `${config.kit.appDir}/version.json`;
process.env.VITE_SVELTEKIT_APP_VERSION_POLL_INTERVAL = `${config.kit.version.pollInterval}`;

create_app({
config,
manifest_data,
cwd
});

copy_assets(path.join(config.kit.outDir, 'runtime'));

process.env.VITE_SVELTEKIT_AMP = config.kit.amp ? 'true' : '';

const client_out_dir = `${output_dir}/client/${config.kit.appDir}`;
Expand Down
10 changes: 3 additions & 7 deletions packages/kit/src/core/build/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import fs from 'fs';
import path from 'path';
import { mkdirp, rimraf, posixify } from '../../utils/filesystem.js';
import create_manifest_data from '../create_manifest_data/index.js';
import * as sync from '../sync/sync.js';
import { get_runtime_path, resolve_entry } from '../utils.js';
import { generate_manifest } from '../generate_manifest/index.js';
import { build_service_worker } from './build_service_worker.js';
import { build_client } from './build_client.js';
import { build_server } from './build_server.js';
import { prerender } from './prerender/prerender.js';
import { generate_tsconfig } from '../tsconfig.js';

/**
* @param {import('types').ValidatedConfig} config
Expand All @@ -25,7 +24,7 @@ export async function build(config, { log }) {
rimraf(output_dir);
mkdirp(output_dir);

generate_tsconfig(config);
const { manifest_data } = sync.all(config);

const options = {
cwd,
Expand All @@ -36,10 +35,7 @@ export async function build(config, { log }) {
// used relative paths, I _think_ this could get fixed. Issue here:
// https://github.com/vitejs/vite/issues/2009
assets_base: `${config.kit.paths.assets || config.kit.paths.base}/${config.kit.appDir}/`,
manifest_data: create_manifest_data({
config,
cwd
}),
manifest_data,
output_dir,
client_entry_file: path.relative(cwd, `${get_runtime_path(config)}/client/start.js`),
service_worker_entry_file: resolve_entry(config.kit.files.serviceWorker),
Expand Down
263 changes: 0 additions & 263 deletions packages/kit/src/core/create_app/index.js

This file was deleted.

Loading

0 comments on commit 9545b8b

Please sign in to comment.