Skip to content

Commit

Permalink
Clean up astro deps (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
drwpow authored and matthewp committed Sep 30, 2021
1 parent 67b1773 commit a8b9436
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 177 deletions.
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,19 @@
"@changesets/cli": "^2.16.0",
"@octokit/action": "^3.15.4",
"@types/jest": "^27.0.2",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.18.0",
"autoprefixer": "^10.2.6",
"cheerio": "^1.0.0-rc.10",
"cheerio-select-tmp": "^0.1.1",
"@typescript-eslint/eslint-plugin": "^4.31.2",
"@typescript-eslint/parser": "^4.31.2",
"del": "^6.0.0",
"esbuild": "^0.11.17",
"eslint": "^7.25.0",
"esbuild": "^0.12.28",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-prettier": "^4.0.0",
"execa": "^5.0.0",
"jest": "^27.2.1",
"lerna": "^4.0.0",
"prettier": "^2.3.2",
"prettier": "^2.4.1",
"tiny-glob": "^0.2.8",
"typescript": "^4.4.2"
"typescript": "^4.4.3"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
Expand Down
22 changes: 12 additions & 10 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,30 @@
"test": "NODE_OPTIONS=--experimental-vm-modules jest"
},
"dependencies": {
"@astrojs/compiler": "^0.1.0-canary.37",
"@astrojs/compiler": "^0.1.0-canary.45",
"@astrojs/markdown-remark": "^0.3.1",
"@babel/core": "^7.15.0",
"@types/rimraf": "^3.0.2",
"@astrojs/renderer-preact": "^0.2.2",
"@astrojs/renderer-react": "^0.2.1",
"@astrojs/renderer-svelte": "^0.1.2",
"@astrojs/renderer-vue": "^0.1.8",
"@babel/core": "^7.15.5",
"@web/rollup-plugin-html": "^1.9.1",
"astring": "^1.7.5",
"cheerio": "^1.0.0-rc.10",
"ci-info": "^3.2.0",
"connect": "^3.7.0",
"del": "^6.0.0",
"es-module-lexer": "^0.7.1",
"esbuild": "^0.12.23",
"esbuild": "^0.12.28",
"estree-util-value-to-estree": "^1.2.0",
"fast-xml-parser": "^3.19.0",
"fdir": "^5.1.0",
"html-entities": "^2.3.2",
"kleur": "^4.1.4",
"mime": "^2.5.2",
"morphdom": "^2.6.1",
"node-fetch": "^2.6.1",
"path-to-regexp": "^6.2.0",
"picomatch": "^2.3.0",
"rimraf": "^3.0.2",
"sass": "^1.38.1",
"sass": "^1.42.0",
"semver": "^7.3.5",
"send": "^0.17.1",
"shiki": "^0.9.10",
Expand All @@ -72,7 +73,7 @@
"strip-ansi": "^7.0.1",
"supports-esm": "^1.0.0",
"tiny-glob": "^0.2.8",
"vite": "^2.5.7",
"vite": "^2.5.10",
"yargs-parser": "^20.2.9",
"zod": "^3.8.1"
},
Expand All @@ -82,7 +83,8 @@
"@types/mime": "^2.0.3",
"@types/node-fetch": "^2.5.12",
"@types/send": "^0.17.1",
"@types/yargs-parser": "^20.2.1"
"@types/yargs-parser": "^20.2.1",
"cheerio": "^1.0.0-rc.10"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class AstroBuilder {
if (this.config.buildOptions.sitemap && this.config.buildOptions.site) {
const sitemapStart = performance.now();
const sitemap = generateSitemap(input.map(({ name }) => new URL(`/${name}`, this.config.buildOptions.site).href));
const sitemapPath = new URL('sitemap.xml', this.config.dist);
const sitemapPath = new URL('./sitemap.xml', this.config.dist);
await fs.promises.mkdir(new URL('./', sitemapPath), { recursive: true });
await fs.promises.writeFile(sitemapPath, sitemap, 'utf8');
sitemapTime = performance.now() - sitemapStart;
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/build/stats.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import cheerio from 'cheerio';
import * as eslexer from 'es-module-lexer';
import { fdir } from 'fdir';
import fetch from 'node-fetch';
import fs from 'fs';
import slash from 'slash';
import glob from 'tiny-glob';
import { fileURLToPath } from 'url';

type FileSizes = { [file: string]: number };
Expand All @@ -30,8 +30,8 @@ interface HTMLOutput {

/** Scan any directory */
async function scan(cwd: URL, pattern: string): Promise<URL[]> {
const results: string[] = (await new fdir().glob(pattern).withFullPaths().crawl(fileURLToPath(cwd)).withPromise()) as any;
return results.map((filepath) => new URL(`file://${slash(filepath)}`));
const results = await glob(pattern, { cwd: fileURLToPath(cwd) });
return results.map((filepath) => new URL(slash(filepath), cwd));
}

/** get total HTML size */
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/cli/reload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { LogOptions } from '../logger';
import rimraf from 'rimraf';
import del from 'del';
import { fileURLToPath } from 'url';
import { defaultLogDestination, defaultLogLevel, info } from '../logger.js';

Expand All @@ -12,7 +12,7 @@ export async function reload(cwd: string) {
try {
info(logging, 'reload', `Clearing the cache...`);
const viteCache = new URL('node_modules/.vite/', `file://${cwd}/`);
rimraf.sync(fileURLToPath(viteCache));
del.sync(fileURLToPath(viteCache));
return 0;
} catch {
return 1;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ interface LoadConfigOptions {

/** Adds '/' to end of string but doesn’t double-up */
function addTrailingSlash(str: string): string {
return str.replace(/\/+?$/, '/');
return str.replace(/\/*$/, '/');
}

interface LoadConfigOptions {
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/runtime/ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { BuildResult } from 'esbuild';
import type { ViteDevServer } from 'vite';
import type { AstroConfig, ComponentInstance, GetStaticPathsResult, Params, Props, RouteCache, RouteData, RuntimeMode, SSRError } from '../@types/astro';
import type { LogOptions } from '../logger';
import type { PathsOutput } from 'fdir';

import cheerio from 'cheerio';
import * as eslexer from 'es-module-lexer';
Expand Down
17 changes: 8 additions & 9 deletions packages/astro/test/astro-expr.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* UNCOMMENT: merge https://github.com/snowpackjs/astro-compiler-next/pull/21
* UNCOMMENT: @astrojs/compiler transform error
import cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
Expand All @@ -14,9 +14,8 @@ beforeAll(async () => {
await fixture.build();
});
describe('Expressions', () => {
test.skip('Can load page', async () => {
test('Can load page', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
Expand All @@ -25,7 +24,7 @@ describe('Expressions', () => {
}
});
test.skip('Ignores characters inside of strings', async () => {
test('Ignores characters inside of strings', async () => {
const html = await fixture.readFile('/strings/index.html');
const $ = cheerio.load(html);
Expand All @@ -34,7 +33,7 @@ describe('Expressions', () => {
}
});
test.skip('Ignores characters inside of line comments', async () => {
test('Ignores characters inside of line comments', async () => {
const html = await fixture.readFile('/line-comments/index.html');
const $ = cheerio.load(html);
Expand All @@ -43,7 +42,7 @@ describe('Expressions', () => {
}
});
test.skip('Ignores characters inside of multiline comments', async () => {
test('Ignores characters inside of multiline comments', async () => {
const html = await fixture.readFile('/multiline-comments/index.html');
const $ = cheerio.load(html);
Expand All @@ -52,14 +51,14 @@ describe('Expressions', () => {
}
});
test.skip('Allows multiple JSX children in mustache', async () => {
test('Allows multiple JSX children in mustache', async () => {
const html = await fixture.readFile('/multiple-children/index.html');
expect(html).toEqual(expect.stringContaining('#f'));
expect(html).not.toEqual(expect.stringContaining('#t'));
});
test.skip('Allows <> Fragments in expressions', async () => {
test('Allows <> Fragments in expressions', async () => {
const html = await fixture.readFile('/multiple-children/index.html');
const $ = cheerio.load(html);
Expand All @@ -69,7 +68,7 @@ describe('Expressions', () => {
expect($('#fragment').children('#c')).toHaveLength(1);
});
test.skip('Does not render falsy values using &&', async () => {
test('Does not render falsy values using &&', async () => {
const html = await fixture.readFile('/falsy/index.html');
const $ = cheerio.load(html);
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function loadFixture(inlineConfig) {
inlineConfig.devOptions.port = previewServer.port; // update port for fetch
return previewServer;
},
readFile: (filePath) => fs.promises.readFile(fileURLToPath(config.dist) + filePath, 'utf8'),
readFile: (filePath) => fs.promises.readFile(new URL(filePath.replace(/^\//, ''), config.dist), 'utf8'),
};
}

Expand Down
Loading

0 comments on commit a8b9436

Please sign in to comment.