silgi 0.29.0 → 0.29.1

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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from 'citty';
3
3
 
4
- const version = "0.29.0";
4
+ const version = "0.29.1";
5
5
  const packageJson = {
6
6
  version: version};
7
7
 
@@ -135,14 +135,15 @@ const command$1 = defineCommand({
135
135
  message: "Select commands to run",
136
136
  required: true,
137
137
  options: {
138
- ...selectedCommands.reduce((acc, cmd) => {
139
- acc[cmd.group || ""] = [
140
- {
141
- label: cmd.name,
142
- value: cmd,
143
- hint: cmd.description
144
- }
145
- ];
138
+ ...selectedCommands.sort((a, b) => (a.order || Infinity) - (b.order || Infinity)).reduce((acc, cmd) => {
139
+ if (!acc[cmd.group || ""]) {
140
+ acc[cmd.group || ""] = [];
141
+ }
142
+ acc[cmd.group || ""].push({
143
+ label: cmd.name,
144
+ value: cmd,
145
+ hint: cmd.description
146
+ });
146
147
  return acc;
147
148
  }, {})
148
149
  }
@@ -2293,6 +2293,7 @@ async function createSilgiCLI(config = {}, opts = {}) {
2293
2293
  silgiCLICtx.set(silgi);
2294
2294
  silgi.hook("close", () => silgiCLICtx.unset());
2295
2295
  }
2296
+ await silgi.hooks.callHook("ready", silgi);
2296
2297
  if (silgi.options.debug) {
2297
2298
  createDebugger(silgi.hooks, { tag: "silgi" });
2298
2299
  silgi.options.plugins.push({
@@ -1,7 +1,7 @@
1
1
  import { watchConfig, loadConfig } from 'c12';
2
2
  import { resolveCompatibilityDatesFromEnv, formatDate, resolveCompatibilityDates } from 'compatx';
3
3
  import { klona } from 'klona/full';
4
- import { isDebug, isTest } from 'std-env';
4
+ import { isTest, isDebug } from 'std-env';
5
5
  import consola from 'consola';
6
6
  import { colors } from 'consola/utils';
7
7
  import { relative, join, resolve, dirname, isAbsolute } from 'pathe';
@@ -16,7 +16,7 @@ import { defu } from 'defu';
16
16
 
17
17
  const SilgiCLIDefaults = {
18
18
  // General
19
- debug: isDebug,
19
+ debug: isDebug === true ? true : void 0,
20
20
  // timing: isDebug,
21
21
  logLevel: isTest ? 1 : 3,
22
22
  // runtimeConfig: { app: {}, silgi: {} },
@@ -11,7 +11,12 @@ declare function addNPMPackage(data: {
11
11
  version?: string;
12
12
  isDev?: boolean;
13
13
  when?: boolean;
14
- }[]): Promise<void>;
14
+ }[] | {
15
+ name: string;
16
+ version?: string;
17
+ isDev?: boolean;
18
+ when?: boolean;
19
+ }): Promise<void>;
15
20
 
16
21
  declare function hasError(type: SilgiCLI['errors'][0]['type'], silgi?: SilgiCLI): boolean;
17
22
 
@@ -70,7 +70,7 @@ async function addCommands(data) {
70
70
  const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
71
71
  async function addNPMPackage(data) {
72
72
  const silgi = useSilgiCLI$1();
73
- for (const item of data) {
73
+ for (const item of toArray(data)) {
74
74
  if (item.when === false) {
75
75
  continue;
76
76
  }
@@ -1,5 +1,4 @@
1
- import { defineSilgiPreset } from "silgi/kit";
2
- import { peerDependencies } from "silgi/meta";
1
+ import { addNPMPackage, defineSilgiPreset } from "silgi/kit";
3
2
  const h3 = defineSilgiPreset(
4
3
  {
5
4
  static: true,
@@ -11,11 +10,11 @@ const h3 = defineSilgiPreset(
11
10
  crawlLinks: true
12
11
  },
13
12
  hooks: {
14
- "prepare:installPackages": async (packages) => {
15
- packages.dependencies = {
16
- ...packages.dependencies,
17
- h3: peerDependencies.h3
18
- };
13
+ ready: async () => {
14
+ await addNPMPackage({
15
+ name: "h3",
16
+ isDev: true
17
+ });
19
18
  }
20
19
  }
21
20
  },
@@ -1,5 +1,4 @@
1
- import { defineSilgiPreset } from "silgi/kit";
2
- import { peerDependencies } from "silgi/meta";
1
+ import { addNPMPackage, defineSilgiPreset } from "silgi/kit";
3
2
  const nitro = defineSilgiPreset(
4
3
  {
5
4
  static: true,
@@ -26,11 +25,11 @@ const nitro = defineSilgiPreset(
26
25
  ]
27
26
  },
28
27
  hooks: {
29
- "prepare:installPackages": async (packages) => {
30
- packages.dependencies = {
31
- ...packages.dependencies,
32
- h3: peerDependencies.h3
33
- };
28
+ ready: async () => {
29
+ await addNPMPackage({
30
+ name: "h3",
31
+ isDev: true
32
+ });
34
33
  }
35
34
  },
36
35
  storages: ["data", "/assets"]
@@ -1,5 +1,4 @@
1
- import { defineSilgiPreset } from "silgi/kit";
2
- import { peerDependencies } from "silgi/meta";
1
+ import { addNPMPackage, defineSilgiPreset } from "silgi/kit";
3
2
  const nuxt = defineSilgiPreset(
4
3
  {
5
4
  static: true,
@@ -27,11 +26,11 @@ const nuxt = defineSilgiPreset(
27
26
  ]
28
27
  },
29
28
  hooks: {
30
- "prepare:installPackages": async (packages) => {
31
- packages.dependencies = {
32
- ...packages.dependencies,
33
- h3: peerDependencies.h3
34
- };
29
+ ready: async () => {
30
+ await addNPMPackage({
31
+ name: "h3",
32
+ isDev: true
33
+ });
35
34
  }
36
35
  },
37
36
  storages: ["data", "/assets"]
@@ -147,6 +147,21 @@ interface ResolvedSilgiTemplate<Options = TemplateDefaultOptions> extends SilgiT
147
147
  modified?: boolean;
148
148
  }
149
149
 
150
+ interface SilgiCommands {
151
+ }
152
+ interface Commands {
153
+ name: string;
154
+ description?: string;
155
+ group: string;
156
+ when?: boolean;
157
+ type: 'function' | 'command';
158
+ tags?: (keyof SilgiCommands)[] | (string | object)[];
159
+ getContents: (data: {
160
+ app: SilgiCLI;
161
+ }) => string;
162
+ order?: number;
163
+ }
164
+
150
165
  interface SilgiCLIHooks extends SilgiHooks {
151
166
  /**
152
167
  * Called after Silgi initialization, when the Silgi instance is ready to work.
@@ -263,7 +278,7 @@ interface SilgiCLIHooks extends SilgiHooks {
263
278
  */
264
279
  'app:templatesGenerated': (app: SilgiCLI, templates: ResolvedSilgiTemplate[], options?: GenerateAppOptions) => HookResult;
265
280
  'scanFiles:done': (app: SilgiCLI) => HookResult;
266
- 'prepare:commands': (commands: SilgiCLI['commands']) => HookResult;
281
+ 'prepare:commands': (commands: Commands[]) => HookResult;
267
282
  }
268
283
  type TSReference = {
269
284
  types: string;
@@ -1147,20 +1162,6 @@ interface GraphQLJSON {
1147
1162
  references: any;
1148
1163
  }
1149
1164
 
1150
- interface SilgiCommands {
1151
- }
1152
- interface Commands {
1153
- name: string;
1154
- description?: string;
1155
- group: string;
1156
- when?: boolean;
1157
- type: 'function' | 'command';
1158
- tags?: (keyof SilgiCommands)[] | (string | object)[];
1159
- getContents: (data: {
1160
- app: SilgiCLI;
1161
- }) => string;
1162
- }
1163
-
1164
1165
  interface BaseNamespaceType extends Record<keyof DefaultNamespaces, Record<string, BaseSchemaType<StandardSchemaV1>>> {
1165
1166
  }
1166
1167
  type Namespaces<T extends BaseNamespaceType> = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "silgi",
3
3
  "type": "module",
4
- "version": "0.29.0",
4
+ "version": "0.29.1",
5
5
  "private": false,
6
6
  "sideEffects": false,
7
7
  "exports": {