Fix astro check failure on first try (#8287)
This commit is contained in:
parent
a0955f769f
commit
1d2389cb6f
4 changed files with 36 additions and 24 deletions
7
.changeset/nasty-bikes-double.md
Normal file
7
.changeset/nasty-bikes-double.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Prevent astro check cache issues
|
||||||
|
|
||||||
|
`astro check` hits cache issues in 3.0 causing it never to work on the first try.
|
|
@ -159,6 +159,7 @@
|
||||||
"preferred-pm": "^3.0.3",
|
"preferred-pm": "^3.0.3",
|
||||||
"prompts": "^2.4.2",
|
"prompts": "^2.4.2",
|
||||||
"rehype": "^12.0.1",
|
"rehype": "^12.0.1",
|
||||||
|
"resolve": "^1.22.4",
|
||||||
"semver": "^7.5.4",
|
"semver": "^7.5.4",
|
||||||
"server-destroy": "^1.0.1",
|
"server-destroy": "^1.0.1",
|
||||||
"sharp": "^0.32.5",
|
"sharp": "^0.32.5",
|
||||||
|
@ -195,6 +196,7 @@
|
||||||
"@types/mime": "^3.0.1",
|
"@types/mime": "^3.0.1",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
"@types/prompts": "^2.4.4",
|
"@types/prompts": "^2.4.4",
|
||||||
|
"@types/resolve": "^1.20.2",
|
||||||
"@types/send": "^0.17.1",
|
"@types/send": "^0.17.1",
|
||||||
"@types/server-destroy": "^1.0.1",
|
"@types/server-destroy": "^1.0.1",
|
||||||
"@types/unist": "^2.0.7",
|
"@types/unist": "^2.0.7",
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import boxen from 'boxen';
|
import boxen from 'boxen';
|
||||||
import { execa } from 'execa';
|
import { execa } from 'execa';
|
||||||
import { bold, cyan, dim, magenta } from 'kleur/colors';
|
import { bold, cyan, dim, magenta } from 'kleur/colors';
|
||||||
import { createRequire } from 'node:module';
|
|
||||||
import ora from 'ora';
|
import ora from 'ora';
|
||||||
import prompts from 'prompts';
|
import prompts from 'prompts';
|
||||||
|
import resolvePackage from 'resolve';
|
||||||
import whichPm from 'which-pm';
|
import whichPm from 'which-pm';
|
||||||
import { type Logger } from '../core/logger/core.js';
|
import { type Logger } from '../core/logger/core.js';
|
||||||
|
|
||||||
|
@ -18,11 +18,9 @@ export async function getPackage<T>(
|
||||||
options: GetPackageOptions,
|
options: GetPackageOptions,
|
||||||
otherDeps: string[] = []
|
otherDeps: string[] = []
|
||||||
): Promise<T | undefined> {
|
): Promise<T | undefined> {
|
||||||
const require = createRequire(options.cwd ?? process.cwd());
|
|
||||||
|
|
||||||
let packageImport;
|
let packageImport;
|
||||||
try {
|
try {
|
||||||
require.resolve(packageName, { paths: [options.cwd ?? process.cwd()] });
|
await tryResolve(packageName, options.cwd ?? process.cwd());
|
||||||
|
|
||||||
// The `require.resolve` is required as to avoid Node caching the failed `import`
|
// The `require.resolve` is required as to avoid Node caching the failed `import`
|
||||||
packageImport = await import(packageName);
|
packageImport = await import(packageName);
|
||||||
|
@ -43,6 +41,20 @@ export async function getPackage<T>(
|
||||||
return packageImport as T;
|
return packageImport as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tryResolve(packageName: string, cwd: string) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
resolvePackage(packageName, {
|
||||||
|
basedir: cwd,
|
||||||
|
}, (err) => {
|
||||||
|
if(err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getInstallCommand(packages: string[], packageManager: string) {
|
function getInstallCommand(packages: string[], packageManager: string) {
|
||||||
switch (packageManager) {
|
switch (packageManager) {
|
||||||
case 'npm':
|
case 'npm':
|
||||||
|
|
31
pnpm-lock.yaml
generated
31
pnpm-lock.yaml
generated
|
@ -602,6 +602,9 @@ importers:
|
||||||
rehype:
|
rehype:
|
||||||
specifier: ^12.0.1
|
specifier: ^12.0.1
|
||||||
version: 12.0.1
|
version: 12.0.1
|
||||||
|
resolve:
|
||||||
|
specifier: ^1.22.4
|
||||||
|
version: 1.22.4
|
||||||
semver:
|
semver:
|
||||||
specifier: ^7.5.4
|
specifier: ^7.5.4
|
||||||
version: 7.5.4
|
version: 7.5.4
|
||||||
|
@ -705,6 +708,9 @@ importers:
|
||||||
'@types/prompts':
|
'@types/prompts':
|
||||||
specifier: ^2.4.4
|
specifier: ^2.4.4
|
||||||
version: 2.4.4
|
version: 2.4.4
|
||||||
|
'@types/resolve':
|
||||||
|
specifier: ^1.20.2
|
||||||
|
version: 1.20.2
|
||||||
'@types/send':
|
'@types/send':
|
||||||
specifier: ^0.17.1
|
specifier: ^0.17.1
|
||||||
version: 0.17.1
|
version: 0.17.1
|
||||||
|
@ -8364,7 +8370,7 @@ packages:
|
||||||
babel-plugin-transform-hook-names: 1.0.2
|
babel-plugin-transform-hook-names: 1.0.2
|
||||||
debug: 4.3.4(supports-color@8.1.1)
|
debug: 4.3.4(supports-color@8.1.1)
|
||||||
kolorist: 1.8.0
|
kolorist: 1.8.0
|
||||||
resolve: 1.22.2
|
resolve: 1.22.4
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- preact
|
- preact
|
||||||
- supports-color
|
- supports-color
|
||||||
|
@ -12470,16 +12476,10 @@ packages:
|
||||||
ci-info: 3.8.0
|
ci-info: 3.8.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/is-core-module@2.12.0:
|
|
||||||
resolution: {integrity: sha512-RECHCBCd/viahWmwj6enj19sKbHfJrddi/6cBDsNTKbNq0f7VeaUkBo60BqzvPqo/W54ChS62Z5qyun7cfOMqQ==}
|
|
||||||
dependencies:
|
|
||||||
has: 1.0.3
|
|
||||||
|
|
||||||
/is-core-module@2.13.0:
|
/is-core-module@2.13.0:
|
||||||
resolution: {integrity: sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==}
|
resolution: {integrity: sha512-Z7dk6Qo8pOCp3l4tsX2C5ZVas4V+UxwQodwZhLopL91TX8UyyHEXafPcyoeeWuLrwzHcr3igO78wNLwHJHsMCQ==}
|
||||||
dependencies:
|
dependencies:
|
||||||
has: 1.0.3
|
has: 1.0.3
|
||||||
dev: false
|
|
||||||
|
|
||||||
/is-date-object@1.0.5:
|
/is-date-object@1.0.5:
|
||||||
resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==}
|
resolution: {integrity: sha512-9YQaSxsAiSwcvS33MBk3wTCVnWK+HhF8VZR2jRxehM16QcVOdHqPn4VPHmRK4lSr38n9JriurInLcP90xsYNfQ==}
|
||||||
|
@ -14286,7 +14286,7 @@ packages:
|
||||||
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
|
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
|
||||||
dependencies:
|
dependencies:
|
||||||
hosted-git-info: 2.8.9
|
hosted-git-info: 2.8.9
|
||||||
resolve: 1.22.2
|
resolve: 1.22.4
|
||||||
semver: 5.7.2
|
semver: 5.7.2
|
||||||
validate-npm-package-license: 3.0.4
|
validate-npm-package-license: 3.0.4
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -14888,7 +14888,7 @@ packages:
|
||||||
postcss: 8.4.28
|
postcss: 8.4.28
|
||||||
postcss-value-parser: 4.2.0
|
postcss-value-parser: 4.2.0
|
||||||
read-cache: 1.0.0
|
read-cache: 1.0.0
|
||||||
resolve: 1.22.2
|
resolve: 1.22.4
|
||||||
|
|
||||||
/postcss-initial@4.0.1(postcss@8.4.28):
|
/postcss-initial@4.0.1(postcss@8.4.28):
|
||||||
resolution: {integrity: sha512-0ueD7rPqX8Pn1xJIjay0AZeIuDoF+V+VvMt/uOnn+4ezUKhZM/NokDeP6DwMNyIoYByuN/94IQnt5FEkaN59xQ==}
|
resolution: {integrity: sha512-0ueD7rPqX8Pn1xJIjay0AZeIuDoF+V+VvMt/uOnn+4ezUKhZM/NokDeP6DwMNyIoYByuN/94IQnt5FEkaN59xQ==}
|
||||||
|
@ -15705,14 +15705,6 @@ packages:
|
||||||
resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}
|
resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
||||||
/resolve@1.22.2:
|
|
||||||
resolution: {integrity: sha512-Sb+mjNHOULsBv818T40qSPeRiuWLyaGMa5ewydRLFimneixmVy2zdivRl+AF6jaYPC8ERxGDmFSiqui6SfPd+g==}
|
|
||||||
hasBin: true
|
|
||||||
dependencies:
|
|
||||||
is-core-module: 2.12.0
|
|
||||||
path-parse: 1.0.7
|
|
||||||
supports-preserve-symlinks-flag: 1.0.0
|
|
||||||
|
|
||||||
/resolve@1.22.4:
|
/resolve@1.22.4:
|
||||||
resolution: {integrity: sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==}
|
resolution: {integrity: sha512-PXNdCiPqDqeUou+w1C2eTQbNfxKSuMxqTCuvlmmMsk1NWHL5fRrhY6Pl0qEYYc6+QqGClco1Qj8XnjPego4wfg==}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
@ -15720,7 +15712,6 @@ packages:
|
||||||
is-core-module: 2.13.0
|
is-core-module: 2.13.0
|
||||||
path-parse: 1.0.7
|
path-parse: 1.0.7
|
||||||
supports-preserve-symlinks-flag: 1.0.0
|
supports-preserve-symlinks-flag: 1.0.0
|
||||||
dev: false
|
|
||||||
|
|
||||||
/restore-cursor@4.0.0:
|
/restore-cursor@4.0.0:
|
||||||
resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==}
|
resolution: {integrity: sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==}
|
||||||
|
@ -16603,7 +16594,7 @@ packages:
|
||||||
postcss-load-config: 4.0.1(postcss@8.4.28)
|
postcss-load-config: 4.0.1(postcss@8.4.28)
|
||||||
postcss-nested: 6.0.1(postcss@8.4.28)
|
postcss-nested: 6.0.1(postcss@8.4.28)
|
||||||
postcss-selector-parser: 6.0.13
|
postcss-selector-parser: 6.0.13
|
||||||
resolve: 1.22.2
|
resolve: 1.22.4
|
||||||
sucrase: 3.32.0
|
sucrase: 3.32.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- ts-node
|
- ts-node
|
||||||
|
@ -16830,7 +16821,7 @@ packages:
|
||||||
'@types/json5': 0.0.30
|
'@types/json5': 0.0.30
|
||||||
'@types/resolve': 1.20.2
|
'@types/resolve': 1.20.2
|
||||||
json5: 2.2.3
|
json5: 2.2.3
|
||||||
resolve: 1.22.2
|
resolve: 1.22.4
|
||||||
strip-bom: 4.0.0
|
strip-bom: 4.0.0
|
||||||
type-fest: 3.0.0
|
type-fest: 3.0.0
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue