astro 4.14.1 → 4.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ async function check(flags) {
7
7
  const logger = createLoggerFromFlags(flags);
8
8
  const getPackageOpts = {
9
9
  skipAsk: !!flags.yes || !!flags.y,
10
- cwd: typeof flags.root == "string" ? flags.root : void 0
10
+ cwd: flags.root
11
11
  };
12
12
  const checkPackage = await getPackage(
13
13
  "@astrojs/check",
@@ -1,5 +1,4 @@
1
- import { type Flags } from '../flags.js';
2
- export declare function db({ positionals, flags }: {
3
- positionals: string[];
4
- flags: Flags;
1
+ import type { Arguments } from 'yargs-parser';
2
+ export declare function db({ flags }: {
3
+ flags: Arguments;
5
4
  }): Promise<void>;
@@ -2,12 +2,12 @@ import { resolveConfig } from "../../core/config/config.js";
2
2
  import { apply as applyPolyfill } from "../../core/polyfill.js";
3
3
  import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
4
4
  import { getPackage } from "../install-package.js";
5
- async function db({ positionals, flags }) {
5
+ async function db({ flags }) {
6
6
  applyPolyfill();
7
7
  const logger = createLoggerFromFlags(flags);
8
8
  const getPackageOpts = {
9
9
  skipAsk: !!flags.yes || !!flags.y,
10
- cwd: typeof flags.root == "string" ? flags.root : void 0
10
+ cwd: flags.root
11
11
  };
12
12
  const dbPackage = await getPackage("@astrojs/db", logger, getPackageOpts, []);
13
13
  if (!dbPackage) {
@@ -20,11 +20,7 @@ async function db({ positionals, flags }) {
20
20
  const { cli } = dbPackage;
21
21
  const inlineConfig = flagsToAstroInlineConfig(flags);
22
22
  const { astroConfig } = await resolveConfig(inlineConfig, "build");
23
- const yargsArgs = {
24
- _: positionals,
25
- ...flags
26
- };
27
- await cli({ flags: yargsArgs, config: astroConfig });
23
+ await cli({ flags, config: astroConfig });
28
24
  }
29
25
  export {
30
26
  db
@@ -1,8 +1,7 @@
1
- import type { parseArgs } from 'node:util';
1
+ import type { Arguments } from 'yargs-parser';
2
2
  import type { AstroInlineConfig } from '../@types/astro.js';
3
3
  import { Logger } from '../core/logger/core.js';
4
- export type ParsedArgsResult = ReturnType<typeof parseArgs>;
5
- export type Flags = ParsedArgsResult['values'];
4
+ export type Flags = Arguments;
6
5
  export declare function flagsToAstroInlineConfig(flags: Flags): AstroInlineConfig;
7
6
  /**
8
7
  * The `logging` is usually created from an `AstroInlineConfig`, but some flows like `add`
package/dist/cli/flags.js CHANGED
@@ -13,7 +13,7 @@ function flagsToAstroInlineConfig(flags) {
13
13
  base: typeof flags.base === "string" ? flags.base : void 0,
14
14
  outDir: typeof flags.outDir === "string" ? flags.outDir : void 0,
15
15
  server: {
16
- port: typeof flags.port === "string" ? Number(flags.port) : void 0,
16
+ port: typeof flags.port === "number" ? flags.port : void 0,
17
17
  host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
18
18
  open: typeof flags.open === "string" || typeof flags.open === "boolean" ? flags.open : void 0
19
19
  }
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { parseArgs } from "node:util";
2
1
  import * as colors from "kleur/colors";
2
+ import yargs from "yargs-parser";
3
3
  import { ASTRO_VERSION } from "../core/constants.js";
4
4
  async function printAstroHelp() {
5
5
  const { printHelp } = await import("../core/messages.js");
@@ -43,9 +43,9 @@ function printVersion() {
43
43
  console.log();
44
44
  console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${ASTRO_VERSION}`)}`);
45
45
  }
46
- function resolveCommand(args) {
47
- const cmd = args.positionals[2];
48
- if (args.values.version) return "version";
46
+ function resolveCommand(flags) {
47
+ const cmd = flags._[2];
48
+ if (flags.version) return "version";
49
49
  const supportedCommands = /* @__PURE__ */ new Set([
50
50
  "add",
51
51
  "sync",
@@ -68,8 +68,7 @@ function resolveCommand(args) {
68
68
  }
69
69
  return "help";
70
70
  }
71
- async function runCommand(cmd, args) {
72
- const flags = args.values;
71
+ async function runCommand(cmd, flags) {
73
72
  switch (cmd) {
74
73
  case "help":
75
74
  await printAstroHelp();
@@ -89,7 +88,7 @@ async function runCommand(cmd, args) {
89
88
  }
90
89
  case "telemetry": {
91
90
  const { update } = await import("./telemetry/index.js");
92
- const subcommand = args.positionals[3];
91
+ const subcommand = flags._[3]?.toString();
93
92
  await update(subcommand, { flags });
94
93
  return;
95
94
  }
@@ -100,7 +99,7 @@ async function runCommand(cmd, args) {
100
99
  }
101
100
  case "preferences": {
102
101
  const { preferences } = await import("./preferences/index.js");
103
- const [subcommand, key, value] = args.positionals.slice(3);
102
+ const [subcommand, key, value] = flags._.slice(3).map((v) => v.toString());
104
103
  const exitCode = await preferences(subcommand, key, value, { flags });
105
104
  return process.exit(exitCode);
106
105
  }
@@ -114,7 +113,7 @@ async function runCommand(cmd, args) {
114
113
  switch (cmd) {
115
114
  case "add": {
116
115
  const { add } = await import("./add/index.js");
117
- const packages = args.positionals.slice(3);
116
+ const packages = flags._.slice(3);
118
117
  await add(packages, { flags });
119
118
  return;
120
119
  }
@@ -124,7 +123,7 @@ async function runCommand(cmd, args) {
124
123
  case "link":
125
124
  case "init": {
126
125
  const { db } = await import("./db/index.js");
127
- await db({ positionals: args.positionals, flags });
126
+ await db({ flags });
128
127
  return;
129
128
  }
130
129
  case "dev": {
@@ -163,22 +162,10 @@ async function runCommand(cmd, args) {
163
162
  throw new Error(`Error running ${cmd} -- no command found.`);
164
163
  }
165
164
  async function cli(argv) {
166
- const args = parseArgs({
167
- args: argv,
168
- allowPositionals: true,
169
- strict: false,
170
- options: {
171
- global: { type: "boolean", short: "g" },
172
- host: { type: "string" },
173
- // Can be boolean too, which is covered by `strict: false`
174
- open: { type: "string" }
175
- // Can be boolean too, which is covered by `strict: false`
176
- // TODO: Add more flags here
177
- }
178
- });
179
- const cmd = resolveCommand(args);
165
+ const flags = yargs(argv, { boolean: ["global"], alias: { g: "global" } });
166
+ const cmd = resolveCommand(flags);
180
167
  try {
181
- await runCommand(cmd, args);
168
+ await runCommand(cmd, flags);
182
169
  } catch (err) {
183
170
  const { throwAndExit } = await import("./throw-and-exit.js");
184
171
  await throwAndExit(cmd, err);
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.14.1";
1
+ const ASTRO_VERSION = "4.14.2";
2
2
  const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
3
3
  const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
4
4
  const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
23
23
  await telemetry.record([]);
24
24
  const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
25
25
  const logger = restart.container.logger;
26
- const currentVersion = "4.14.1";
26
+ const currentVersion = "4.14.2";
27
27
  const isPrerelease = currentVersion.includes("-");
28
28
  if (!isPrerelease) {
29
29
  try {
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "4.14.1";
41
+ const version = "4.14.2";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -270,7 +270,7 @@ function printHelp({
270
270
  message.push(
271
271
  linebreak(),
272
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
273
- `v${"4.14.1"}`
273
+ `v${"4.14.2"}`
274
274
  )} ${headline}`
275
275
  );
276
276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.14.1",
3
+ "version": "4.14.2",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -115,8 +115,8 @@
115
115
  "@babel/plugin-transform-react-jsx": "^7.25.2",
116
116
  "@babel/traverse": "^7.25.3",
117
117
  "@babel/types": "^7.25.2",
118
- "@rollup/pluginutils": "^5.1.0",
119
118
  "@oslojs/encoding": "^0.4.1",
119
+ "@rollup/pluginutils": "^5.1.0",
120
120
  "@types/babel__core": "^7.20.5",
121
121
  "@types/cookie": "^0.6.0",
122
122
  "acorn": "^8.12.1",
@@ -168,12 +168,13 @@
168
168
  "vitefu": "^0.2.5",
169
169
  "which-pm": "^3.0.0",
170
170
  "xxhash-wasm": "^1.0.2",
171
+ "yargs-parser": "^21.1.1",
171
172
  "zod": "^3.23.8",
172
173
  "zod-to-json-schema": "^3.23.2",
173
174
  "zod-to-ts": "^1.2.0",
174
175
  "@astrojs/internal-helpers": "0.4.1",
175
- "@astrojs/telemetry": "3.1.0",
176
- "@astrojs/markdown-remark": "5.2.0"
176
+ "@astrojs/markdown-remark": "5.2.0",
177
+ "@astrojs/telemetry": "3.1.0"
177
178
  },
178
179
  "optionalDependencies": {
179
180
  "sharp": "^0.33.3"
@@ -197,6 +198,7 @@
197
198
  "@types/micromatch": "^4.0.9",
198
199
  "@types/prompts": "^2.4.9",
199
200
  "@types/semver": "^7.5.8",
201
+ "@types/yargs-parser": "^21.0.3",
200
202
  "cheerio": "1.0.0",
201
203
  "eol": "^0.9.1",
202
204
  "expect-type": "^0.19.0",