Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start to remove app utils #600

Merged
merged 9 commits into from
Mar 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
start to remove app utils
  • Loading branch information
antony committed Mar 23, 2021
commit e4a63c29e6b977251fa1e1e1a9cf628e0f386bee
3 changes: 1 addition & 2 deletions packages/adapter-begin/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { readFileSync, existsSync } from 'fs';
import { copy } from '@sveltejs/app-utils/files';
import { resolve, join } from 'path';
import parse from '@architect/parser';

Expand Down Expand Up @@ -40,7 +39,7 @@ export default function () {

builder.log.minor('Building lambda...');
const local_lambda_dir = join(__dirname, 'files');
copy(local_lambda_dir, lambda_directory);
builder.copy(local_lambda_dir, lambda_directory);

builder.log.minor('Writing server application...');
builder.copy_server_files(server_directory);
Expand Down
3 changes: 1 addition & 2 deletions packages/adapter-begin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"files"
],
"dependencies": {
"@architect/parser": "^3.0.1",
"@sveltejs/app-utils": "workspace:*"
"@architect/parser": "^3.0.1"
},
"devDependencies": {
"@sveltejs/kit": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-node/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import polka from 'polka';
import { dirname, join } from 'path';
import sirv from 'sirv';
import { parse, URLSearchParams, fileURLToPath } from 'url';
import { get_body } from '@sveltejs/app-utils/http';
import { get_body } from '@sveltejs/kit/http';
// App is a dynamic file built from the application layer.
/*eslint import/no-unresolved: [2, { ignore: ['\.\/app\.js$'] }]*/
import * as app from './app.js';
Expand Down
3 changes: 1 addition & 2 deletions packages/adapter-vercel/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { writeFileSync, mkdirSync, renameSync } = require('fs');
const { resolve, join } = require('path');
const { copy } = require('@sveltejs/app-utils/files');

module.exports = function () {
/** @type {import('@sveltejs/kit').Adapter} */
Expand All @@ -22,7 +21,7 @@ module.exports = function () {
builder.copy_server_files(server_directory);
renameSync(join(server_directory, 'app.js'), join(server_directory, 'app.mjs'));

copy(join(__dirname, 'files'), lambda_directory);
builder.copy(join(__dirname, 'files'), lambda_directory);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any method called copy on the Builder

We really need to introduce type checking everywhere


builder.log.minor('Prerendering static pages...');
await builder.prerender({
Expand Down
3 changes: 0 additions & 3 deletions packages/adapter-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"check-format": "prettier --check . --config ../../.prettierrc --ignore-path .gitignore",
"prepublishOnly": "npm run build"
},
"dependencies": {
"@sveltejs/app-utils": "workspace:*"
},
"devDependencies": {
"@sveltejs/kit": "workspace:*",
"rollup": "^2.41.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-vercel/src/entry.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { URL, URLSearchParams } from 'url';
import { get_body } from '@sveltejs/app-utils/http';
import { get_body } from '@sveltejs/kit/http';

export default async (req, res) => {
const host = `${req.headers['x-forwarded-proto']}:https://${req.headers.host}`;
Expand Down
3 changes: 0 additions & 3 deletions packages/app-utils/.gitignore

This file was deleted.

96 changes: 0 additions & 96 deletions packages/app-utils/CHANGELOG.md

This file was deleted.

3 changes: 0 additions & 3 deletions packages/app-utils/README.md

This file was deleted.

30 changes: 0 additions & 30 deletions packages/app-utils/package.json

This file was deleted.

13 changes: 0 additions & 13 deletions packages/app-utils/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/create-svelte/cli/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { mkdirp } from '@sveltejs/app-utils/files';
import { mkdirp } from '@sveltejs/kit/files';
import fs from 'fs';
import parser from 'gitignore-parser';
import { bold, cyan, gray, green, red } from 'kleur/colors';
Expand Down
1 change: 0 additions & 1 deletion packages/create-svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"devDependencies": {
"@rollup/plugin-json": "^4.1.0",
"@sveltejs/adapter-node": "workspace:*",
"@sveltejs/app-utils": "workspace:*",
"@sveltejs/kit": "workspace:*",
"gitignore-parser": "^0.0.2",
"kleur": "^4.1.4",
Expand Down
8 changes: 7 additions & 1 deletion packages/kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@
"./ssr": {
"import": "./dist/ssr.js"
},
"./http": {
"require": "./dist/http/index.js"
},
"./files": {
"import": "./dist/files/index.js"
},
"./types.d.ts": "./types.d.ts"
},
"types": "types.d.ts"
}
}
12 changes: 11 additions & 1 deletion packages/kit/src/core/adapt/Builder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { copy } from '@sveltejs/app-utils/files';
import { copy, rimraf, mkdirp } from '../filesystem/filesystem.js';
import { prerender } from './prerender.js';

export default class Builder {
Expand Down Expand Up @@ -32,6 +32,16 @@ export default class Builder {
copy(this.#config.kit.files.assets, dest);
}

/** @param {string} path */
rimraf(path) {
rimraf(path);
}

/** @param {string} dir */
mkdirp(dir) {
mkdirp(dir);
}

/** @param {{ force: boolean, dest: string }} opts */
async prerender({ force = false, dest }) {
if (this.#config.kit.prerender.enabled) {
Expand Down
10 changes: 5 additions & 5 deletions packages/kit/src/core/adapt/prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { existsSync, readFileSync, writeFileSync } from 'fs';
import { dirname, join, resolve as resolve_path, sep as path_separator } from 'path';
import { parse, pathToFileURL, resolve, URLSearchParams } from 'url';
import glob from 'tiny-glob/sync.js';
import { mkdirp } from '@sveltejs/app-utils/files';
import { mkdirp } from '../filesystem/filesystem.js';

/** @param {string} html */
function clean_html(html) {
Expand Down Expand Up @@ -72,11 +72,11 @@ export async function prerender({ cwd, out, log, config, force }) {
/** @type {(status: number, path: string) => void} */
const error = config.kit.prerender.force
? (status, path) => {
log.error(`${status} ${path}`);
}
log.error(`${status} ${path}`);
}
: (status, path) => {
throw new Error(`${status} ${path}`);
};
throw new Error(`${status} ${path}`);
};

/** @param {string} path */
async function visit(path) {
Expand Down
Loading