Enable Windows tests
This commit is contained in:
parent
a7e62ded69
commit
69d85d6988
7 changed files with 39 additions and 30 deletions
21
.github/workflows/ci.yml
vendored
21
.github/workflows/ci.yml
vendored
|
@ -18,16 +18,15 @@ jobs:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest]
|
os: [ubuntu-latest]
|
||||||
node_version: [12, 14, 16]
|
node_version: [12, 14, 16]
|
||||||
# TODO: uncomment this (Vite has trouble resolving imports on Windows)
|
include:
|
||||||
# include:
|
- os: windows-latest
|
||||||
# - os: windows-latest
|
node_version: 16
|
||||||
# node_version: 14
|
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
env:
|
env:
|
||||||
LANG: en-us
|
LANG: en-us
|
||||||
name: 'Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
|
name: 'Test: node-${{ matrix.node_version }}, ${{ matrix.os }}'
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Check out
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Set node version to ${{ matrix.node_version }}
|
- name: Set node version to ${{ matrix.node_version }}
|
||||||
|
@ -50,16 +49,16 @@ jobs:
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: 'Lint: node-14, ubuntu-latest'
|
name: 'Lint: node-16, ubuntu-latest'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Set node version to 14
|
- name: Set node version to 16
|
||||||
uses: actions/setup-node@v2
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: 14
|
node-version: 16
|
||||||
cache: 'yarn'
|
cache: 'yarn'
|
||||||
|
|
||||||
- name: Debug
|
- name: Debug
|
||||||
|
@ -77,16 +76,16 @@ jobs:
|
||||||
# NOTE: temporarily disabled until `next` branch can build docs again
|
# NOTE: temporarily disabled until `next` branch can build docs again
|
||||||
# smoke:
|
# smoke:
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
# name: 'Smoke: node-14, ubuntu-latest'
|
# name: 'Smoke: node-16, ubuntu-latest'
|
||||||
# steps:
|
# steps:
|
||||||
# - uses: actions/checkout@v2
|
# - uses: actions/checkout@v2
|
||||||
# with:
|
# with:
|
||||||
# fetch-depth: 0
|
# fetch-depth: 0
|
||||||
|
|
||||||
# - name: Set node version to 14
|
# - name: Set node version to 16
|
||||||
# uses: actions/setup-node@v2
|
# uses: actions/setup-node@v2
|
||||||
# with:
|
# with:
|
||||||
# node-version: 14
|
# node-version: 16
|
||||||
# cache: 'yarn'
|
# cache: 'yarn'
|
||||||
|
|
||||||
# - name: Debug
|
# - name: Debug
|
||||||
|
|
2
.github/workflows/format.yml
vendored
2
.github/workflows/format.yml
vendored
|
@ -6,7 +6,7 @@ on:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
env:
|
env:
|
||||||
node_version: 14
|
node_version: 16
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
format:
|
format:
|
||||||
|
|
14
.github/workflows/stat.yml
vendored
14
.github/workflows/stat.yml
vendored
|
@ -1,24 +1,24 @@
|
||||||
name: 'Collect Stats'
|
name: 'Collect Stats'
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
# * is a special character in YAML so you have to quote this string
|
# * is a special character in YAML so you have to quote this string
|
||||||
- cron: '0 12 * * *'
|
- cron: '0 12 * * *'
|
||||||
|
|
||||||
env:
|
env:
|
||||||
node_version: 14
|
node_version: 16
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
stat:
|
stat:
|
||||||
if: github.repository == 'snowpackjs/astro'
|
if: github.repository == 'snowpackjs/astro'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# Check out code using git
|
- name: Check out
|
||||||
- uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
# Install Node 14
|
- name: Set up Node.js 16.x
|
||||||
- uses: actions/setup-node@v1
|
uses: actions/setup-node@v1
|
||||||
with:
|
with:
|
||||||
version: 14
|
version: 16
|
||||||
- run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
|
- run: yarn install --frozen-lockfile --ignore-engines --ignore-scripts
|
||||||
- run: node scripts/stats/index.js
|
- run: node scripts/stats/index.js
|
||||||
env:
|
env:
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
"astring": "^1.7.5",
|
"astring": "^1.7.5",
|
||||||
"ci-info": "^3.2.0",
|
"ci-info": "^3.2.0",
|
||||||
"connect": "^3.7.0",
|
"connect": "^3.7.0",
|
||||||
"es-module-lexer": "^0.7.1",
|
"es-module-lexer": "^0.9.3",
|
||||||
"esbuild": "^0.13.6",
|
"esbuild": "^0.13.6",
|
||||||
"estree-util-value-to-estree": "^1.2.0",
|
"estree-util-value-to-estree": "^1.2.0",
|
||||||
"fast-xml-parser": "^3.19.0",
|
"fast-xml-parser": "^3.19.0",
|
||||||
|
|
|
@ -5,6 +5,7 @@ import type { TopLevelAstro } from '../../@types/astro-runtime';
|
||||||
import { valueToEstree } from 'estree-util-value-to-estree';
|
import { valueToEstree } from 'estree-util-value-to-estree';
|
||||||
import * as astring from 'astring';
|
import * as astring from 'astring';
|
||||||
import shorthash from 'shorthash';
|
import shorthash from 'shorthash';
|
||||||
|
import { fileURLToPath } from 'url';
|
||||||
export { createMetadata } from './metadata.js';
|
export { createMetadata } from './metadata.js';
|
||||||
|
|
||||||
const { generate, GENERATOR } = astring;
|
const { generate, GENERATOR } = astring;
|
||||||
|
@ -117,7 +118,11 @@ function extractDirectives(inputProps: Record<string | number, any>): ExtractedP
|
||||||
}
|
}
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'client:component-path': {
|
case 'client:component-path': {
|
||||||
extracted.hydration.componentUrl = value;
|
try {
|
||||||
|
extracted.hydration.componentUrl = fileURLToPath(new URL(`file://${value}`));
|
||||||
|
} catch {
|
||||||
|
extracted.hydration.componentUrl = value;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'client:component-export': {
|
case 'client:component-export': {
|
||||||
|
@ -365,13 +370,17 @@ export async function renderToString(result: SSRResult, componentFactory: AstroC
|
||||||
const uniqueElements = (item: any, index: number, all: any[]) => {
|
const uniqueElements = (item: any, index: number, all: any[]) => {
|
||||||
const props = JSON.stringify(item.props);
|
const props = JSON.stringify(item.props);
|
||||||
const children = item.children;
|
const children = item.children;
|
||||||
return index === all.findIndex(i => JSON.stringify(i.props) === props && i.children == children)
|
return index === all.findIndex((i) => JSON.stringify(i.props) === props && i.children == children);
|
||||||
}
|
};
|
||||||
|
|
||||||
export async function renderPage(result: SSRResult, Component: AstroComponentFactory, props: any, children: any) {
|
export async function renderPage(result: SSRResult, Component: AstroComponentFactory, props: any, children: any) {
|
||||||
const template = await renderToString(result, Component, props, children);
|
const template = await renderToString(result, Component, props, children);
|
||||||
const styles = Array.from(result.styles).filter(uniqueElements).map((style) => renderElement('style', style));
|
const styles = Array.from(result.styles)
|
||||||
const scripts = Array.from(result.scripts).filter(uniqueElements).map((script) => renderElement('script', script));
|
.filter(uniqueElements)
|
||||||
|
.map((style) => renderElement('style', style));
|
||||||
|
const scripts = Array.from(result.scripts)
|
||||||
|
.filter(uniqueElements)
|
||||||
|
.map((script) => renderElement('script', script));
|
||||||
return template.replace('</head>', styles.join('\n') + scripts.join('\n') + '</head>');
|
return template.replace('</head>', styles.join('\n') + scripts.join('\n') + '</head>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,8 @@ export default function astro({ config, devServer }: AstroPluginOptions): vite.P
|
||||||
}
|
}
|
||||||
// pages and layouts should be transformed as full documents (implicit <head> <body> etc)
|
// pages and layouts should be transformed as full documents (implicit <head> <body> etc)
|
||||||
// everything else is treated as a fragment
|
// everything else is treated as a fragment
|
||||||
const isPage = id.startsWith(fileURLToPath(config.pages)) || id.startsWith(fileURLToPath(config.layouts));
|
const normalizedID = fileURLToPath(new URL(`file://${id}`));
|
||||||
|
const isPage = normalizedID.startsWith(fileURLToPath(config.pages)) || id.startsWith(fileURLToPath(config.layouts));
|
||||||
let source = await fs.promises.readFile(id, 'utf8');
|
let source = await fs.promises.readFile(id, 'utf8');
|
||||||
let tsResult: TransformResult | undefined;
|
let tsResult: TransformResult | undefined;
|
||||||
|
|
||||||
|
|
|
@ -4074,10 +4074,10 @@ es-abstract@^1.18.0-next.2, es-abstract@^1.18.5:
|
||||||
string.prototype.trimstart "^1.0.4"
|
string.prototype.trimstart "^1.0.4"
|
||||||
unbox-primitive "^1.0.1"
|
unbox-primitive "^1.0.1"
|
||||||
|
|
||||||
es-module-lexer@^0.7.1:
|
es-module-lexer@^0.9.3:
|
||||||
version "0.7.1"
|
version "0.9.3"
|
||||||
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.7.1.tgz#c2c8e0f46f2df06274cdaf0dd3f3b33e0a0b267d"
|
resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-0.9.3.tgz#6f13db00cc38417137daf74366f535c8eb438f19"
|
||||||
integrity sha512-MgtWFl5No+4S3TmhDmCz2ObFGm6lEpTnzbQi+Dd+pw4mlTIZTmM2iAs5gRlmx5zS9luzobCSBSI90JM/1/JgOw==
|
integrity sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==
|
||||||
|
|
||||||
es-to-primitive@^1.2.1:
|
es-to-primitive@^1.2.1:
|
||||||
version "1.2.1"
|
version "1.2.1"
|
||||||
|
|
Loading…
Reference in a new issue