kizlo 0.15.0 → 0.15.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.
@@ -1,4 +1,4 @@
1
- import { approveBuildsCommand, cleanupWorkspaceArtifacts, detectInvokingPackageManager, detectPackageManager, ensureGitignored, findWorkspaceRoot, initGitRepository, installArgs, isCommandAvailable, isGitRepository, isWorkspaceMember, runCommandCapturedAsync, tokenizeCommand } from "../utils.js";
1
+ import { aliasWithSlash, approveBuildsCommand, cleanupWorkspaceArtifacts, detectInvokingPackageManager, detectPackageManager, effectiveAlias, ensureGitignored, findWorkspaceRoot, initGitRepository, installArgs, isCommandAvailable, isGitRepository, isWorkspaceMember, runCommandCapturedAsync, tokenizeCommand } from "../utils.js";
2
2
  import { fetchRegistry, listTemplates, resolveRegistry } from "../presets/source.js";
3
3
  import { adaptFile, changesFor, fileEntries, minCliError, patchEntries, readManifest, resolveDependencies } from "../presets/template.js";
4
4
  import { collectConnectionFromEnv, collectConnectionInteractively, collectTemplatePrompts, nextStepsLines, orCancel, pickAppPort, provisionLocalWordPress, readEnvExample, resolveEnvKeys, selectPackageManager, syncRemote, validate, withApiPath, writeEnv } from "./_setup.js";
@@ -183,13 +183,16 @@ function bootstrapArgs(manifest, pm, name, promptArgs = {}) {
183
183
  * files are written with `force`, silently replacing the framework defaults.
184
184
  */
185
185
  async function applyManifestWiring(dir, templateDir, manifest, opts) {
186
- const { alias, kizloPath } = manifest.config;
186
+ const { kizloPath } = manifest.config;
187
+ const hasSrcDir = fs.existsSync(path.join(dir, "src"));
188
+ const alias = aliasWithSlash(effectiveAlias(dir, kizloPath, manifest.config.alias));
187
189
  const scaffold = buildScaffoldContext(dir, {
188
190
  dirRel: kizloPath,
189
- hasSrcDir: fs.existsSync(path.join(dir, "src")),
191
+ hasSrcDir,
190
192
  alias,
191
193
  clientUrl: void 0
192
194
  });
195
+ if (manifest.config.alias && !alias) p.log.warn(`The ${manifest.name ?? manifest.id} scaffold declares no tsconfig path for \`${aliasWithSlash(manifest.config.alias)}\`, so Kizlo wrote relative imports instead.`);
193
196
  recordDependencies(dir, manifest);
194
197
  const changes = changesFor(manifest, "create", { includeExamples: opts.includeExamples });
195
198
  const files = [{
@@ -1,4 +1,4 @@
1
- import { addDependencyArgs, aliasWithSlash, detectImportAlias, detectInvokingPackageManager, detectPackageManager, ensureGitignored, getVersion, loadEnvFiles, persistPackageManagerField, readPersistedAlias, runCommandAsync } from "../utils.js";
1
+ import { addDependencyArgs, aliasWithSlash, detectImportAlias, detectInvokingPackageManager, detectPackageManager, effectiveAlias, ensureGitignored, getVersion, loadEnvFiles, persistPackageManagerField, readPersistedAlias, runCommandAsync } from "../utils.js";
2
2
  import { DEFAULT_REGISTRY, detectTemplates, fetchRegistry, isSingleTemplate, listTemplates, resolveRegistry } from "../presets/source.js";
3
3
  import { adaptFile, changesFor, fileEntries, isOlderVersion, minCliError, patchEntries, readManifest, renderNote, resolveDependencies, unmetRequirement } from "../presets/template.js";
4
4
  import { collectConnectionFromEnv, collectConnectionInteractively, dirPath, envConflicts, nextStepsNote, orCancel, provisionLocalWordPress, readEnvExample, resolveEnvKeys, selectPackageManager, syncRemote, validate, withApiPath, writeEnv } from "./_setup.js";
@@ -254,13 +254,15 @@ const init = defineCommand({
254
254
  ...aliasCtx,
255
255
  envKeys
256
256
  }) : await collectInteractively(aliasCtx);
257
- setup.alias = aliasWithSlash(setup.alias);
257
+ const dirRel = setup.dir.replace(/^\.\//, "").replace(/\/+$/, "");
258
+ const requestedAlias = aliasWithSlash(setup.alias);
259
+ setup.alias = aliasWithSlash(effectiveAlias(cwd, dirRel, setup.alias));
260
+ const droppedAlias = requestedAlias && !setup.alias ? requestedAlias : void 0;
258
261
  if (apiPath && setup.baseUrl) setup.baseUrl = withApiPath(setup.baseUrl, apiPath);
259
262
  const includeExamples = yes ? true : orCancel(await p.confirm({
260
263
  message: "Add example pages?",
261
264
  initialValue: true
262
265
  }));
263
- const dirRel = setup.dir.replace(/^\.\//, "").replace(/\/+$/, "");
264
266
  const serverDirRel = path.join(dirRel, "server");
265
267
  const clientUrl = setup.siteUrl && !sameOrigin(setup.siteUrl, setup.baseUrl) ? setup.baseUrl : void 0;
266
268
  const scaffold = buildScaffoldContext(cwd, {
@@ -306,6 +308,7 @@ const init = defineCommand({
306
308
  }
307
309
  if (shouldPersistPm) persistPackageManagerField(cwd, pm);
308
310
  const warnings = [];
311
+ if (droppedAlias) warnings.push(`No tsconfig path maps \`${droppedAlias}\` onto ${dirRel}, so relative imports were written instead. Add \`"${droppedAlias}*": ["./${hasSrcDir ? "src/" : ""}*"]\` to your tsconfig \`paths\` and re-run to use the alias.`);
309
312
  const scaffolded = [];
310
313
  let gitignore = "present";
311
314
  const kizloSpec = `kizlo@${manifest.dependencies?.kizlo ?? `^${getVersion()}`}`;
package/dist/cli/utils.js CHANGED
@@ -78,9 +78,14 @@ function relativeImport(targetRel, fromDirRel) {
78
78
  * Detects an import alias from tsconfig `paths` that covers `targetRel`, returning
79
79
  * `{ prefix, importPath }`. The prefix is what `init` persists to kizlo.config;
80
80
  * the import path is the full specifier. Returns undefined when no alias matches.
81
+ * `preferred` (with or without its trailing slash) names the prefix the caller would
82
+ * rather have and wins over an earlier-declared one — a project mapping both `#/*` and
83
+ * `@/*` onto the same root would otherwise silently switch to whichever it declares first.
81
84
  */
82
- function detectImportAlias(cwd, targetRel) {
85
+ function detectImportAlias(cwd, targetRel, preferred) {
83
86
  const target = targetRel.split(path.sep).join("/").replace(/\/+$/, "");
87
+ const want = preferred?.replace(/\/+$/, "");
88
+ let fallback;
84
89
  for (const [alias, mappings] of Object.entries(readTsconfigPaths(cwd) ?? {})) {
85
90
  if (!alias.endsWith("/*")) continue;
86
91
  const prefix = alias.slice(0, -2);
@@ -88,12 +93,16 @@ function detectImportAlias(cwd, targetRel) {
88
93
  if (!mapping.endsWith("/*")) continue;
89
94
  const base = mapping.slice(0, -2).replace(/^\.\//, "").replace(/^\.$/, "").replace(/\/+$/, "");
90
95
  const baseSlash = base ? `${base}/` : "";
91
- if (target === base || target.startsWith(baseSlash)) return {
96
+ if (target !== base && !target.startsWith(baseSlash)) continue;
97
+ const match = {
92
98
  prefix,
93
99
  importPath: `${prefix}/${target.slice(baseSlash.length)}`
94
100
  };
101
+ if (prefix === want) return match;
102
+ fallback ??= match;
95
103
  }
96
104
  }
105
+ return fallback;
97
106
  }
98
107
  /**
99
108
  * Normalize an alias prefix to the canonical `@/` form — the way an import alias is actually written and
@@ -104,19 +113,24 @@ function aliasWithSlash(alias) {
104
113
  return alias ? `${alias.replace(/\/+$/, "")}/` : "";
105
114
  }
106
115
  /**
107
- * Builds an import specifier for `targetRel` from `fromDirRel`. With an explicit
108
- * `alias` prefix (from kizlo.config), builds `<alias>/<target>`; an empty alias
109
- * forces a relative import. Without one, detects from tsconfig, else relative.
116
+ * Builds an import specifier for `targetRel` from `fromDirRel`. An empty `alias` forces a relative
117
+ * import; any other value is a preference, checked against tsconfig `paths` rather than asserted.
118
+ * An alias the project never declares falls back to relative, which always resolves — writing
119
+ * `@/lib/kizlo/server` into a project with no `@` mapping breaks its typecheck and its build.
110
120
  */
111
121
  function resolveModuleImport(cwd, targetRel, fromDirRel, alias) {
112
- const target = targetRel.split(path.sep).join("/").replace(/\/+$/, "");
113
- if (alias !== void 0) {
114
- if (alias === "") return relativeImport(targetRel, fromDirRel);
115
- const prefix = alias.replace(/\/+$/, "");
116
- const base = detectImportAlias(cwd, targetRel);
117
- return base && base.prefix === prefix ? base.importPath : `${prefix}/${target.replace(/^src\//, "")}`;
118
- }
119
- return detectImportAlias(cwd, targetRel)?.importPath ?? relativeImport(targetRel, fromDirRel);
122
+ if (alias === "") return relativeImport(targetRel, fromDirRel);
123
+ return detectImportAlias(cwd, targetRel, alias)?.importPath ?? relativeImport(targetRel, fromDirRel);
124
+ }
125
+ /**
126
+ * The alias imports will really be written through, once the requested one is checked against the
127
+ * project's tsconfig — `""` when nothing declared there covers `targetRel`. The single answer
128
+ * `create` and `init` persist to kizlo.config, show in their summary and warn from, so all three
129
+ * agree with what {@link resolveModuleImport} goes on to emit.
130
+ */
131
+ function effectiveAlias(cwd, targetRel, requested) {
132
+ if (requested === "") return "";
133
+ return detectImportAlias(cwd, targetRel, requested)?.prefix ?? "";
120
134
  }
121
135
  /**
122
136
  * Loads the project's `.env` files into `process.env`. The single place env
@@ -624,4 +638,4 @@ function groupDefault(subCommandNames, run) {
624
638
  }
625
639
 
626
640
  //#endregion
627
- export { DEFAULT_ENV_KEYS, addDependencyArgs, aliasWithSlash, approveBuildsCommand, availablePackageManagers, cleanupWorkspaceArtifacts, detectImportAlias, detectInvokingPackageManager, detectPackageManager, ensureGitignored, envGroups, envKeysPresent, findWorkspaceRoot, getVersion, groupDefault, initGitRepository, installArgs, isCommandAvailable, isGitRepository, isWorkspaceMember, loadEnvFiles, mergeEnv, persistPackageManagerField, pickStackPort, readPersistedAlias, readTsconfigPaths, resolveModuleImport, runCommandAsync, runCommandCapturedAsync, tokenizeCommand, withSpinner, writeFileIfAbsent };
641
+ export { DEFAULT_ENV_KEYS, addDependencyArgs, aliasWithSlash, approveBuildsCommand, availablePackageManagers, cleanupWorkspaceArtifacts, detectImportAlias, detectInvokingPackageManager, detectPackageManager, effectiveAlias, ensureGitignored, envGroups, envKeysPresent, findWorkspaceRoot, getVersion, groupDefault, initGitRepository, installArgs, isCommandAvailable, isGitRepository, isWorkspaceMember, loadEnvFiles, mergeEnv, persistPackageManagerField, pickStackPort, readPersistedAlias, readTsconfigPaths, resolveModuleImport, runCommandAsync, runCommandCapturedAsync, tokenizeCommand, withSpinner, writeFileIfAbsent };
@@ -18,7 +18,10 @@ function createNextCookiesInterface() {
18
18
  const cookies = (await import("next/headers")).cookies;
19
19
  const cookieJar = await cookies();
20
20
  try {
21
- for (const cookie of cookieList) cookieJar.delete(cookie.name);
21
+ for (const cookie of cookieList) cookieJar.delete({
22
+ name: cookie.name,
23
+ ...cookie.options
24
+ });
22
25
  } catch {}
23
26
  }
24
27
  };
package/dist/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "0.15.0";
2
+ var version = "0.15.2";
3
3
 
4
4
  //#endregion
5
5
  export { version };
package/dist/router.d.ts CHANGED
@@ -179,7 +179,7 @@ declare const ROUTER_MAP: {
179
179
  include?: string | number | (string | number)[] | undefined;
180
180
  offset?: string | number | undefined;
181
181
  order?: "asc" | "desc" | undefined;
182
- orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | undefined;
182
+ orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | undefined;
183
183
  searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
184
184
  slug?: string | string[] | undefined;
185
185
  taxRelation?: "AND" | "OR" | undefined;
@@ -511,7 +511,7 @@ declare const ROUTER_MAP: {
511
511
  include?: string | number | (string | number)[] | undefined;
512
512
  offset?: string | number | undefined;
513
513
  order?: "asc" | "desc" | undefined;
514
- orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | "menu_order" | undefined;
514
+ orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "modified" | "relevance" | "include_slugs" | "menu_order" | undefined;
515
515
  searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
516
516
  slug?: string | string[] | undefined;
517
517
  parent?: string | number | (string | number)[] | undefined;
@@ -772,7 +772,7 @@ declare const ROUTER_MAP: {
772
772
  exclude?: string | number | (string | number)[] | undefined;
773
773
  include?: string | number | (string | number)[] | undefined;
774
774
  order?: "asc" | "desc" | undefined;
775
- orderBy?: "id" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | "count" | undefined;
775
+ orderBy?: "id" | "count" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | undefined;
776
776
  hideEmpty?: string | boolean | undefined;
777
777
  parent?: string | number | undefined;
778
778
  post?: string | number | undefined;
@@ -988,7 +988,7 @@ declare const ROUTER_MAP: {
988
988
  exclude?: string | number | (string | number)[] | undefined;
989
989
  include?: string | number | (string | number)[] | undefined;
990
990
  order?: "asc" | "desc" | undefined;
991
- orderBy?: "id" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | "count" | undefined;
991
+ orderBy?: "id" | "count" | "slug" | "name" | "description" | "include" | "include_slugs" | "term_group" | undefined;
992
992
  hideEmpty?: string | boolean | undefined;
993
993
  post?: string | number | undefined;
994
994
  slug?: string | string[] | undefined;
@@ -1151,7 +1151,7 @@ declare const ROUTER_MAP: {
1151
1151
  sitemaps: {
1152
1152
  list: Procedure<"internal", {}, {
1153
1153
  key: string;
1154
- type: "author" | "post_type" | "taxonomy";
1154
+ type: "post_type" | "taxonomy" | "author";
1155
1155
  pages: number;
1156
1156
  lastmod: string;
1157
1157
  }[], DefinedErrorMapLike>;
@@ -1159,7 +1159,7 @@ declare const ROUTER_MAP: {
1159
1159
  origin: string;
1160
1160
  sitemaps: {
1161
1161
  key: string;
1162
- type: "author" | "post_type" | "taxonomy";
1162
+ type: "post_type" | "taxonomy" | "author";
1163
1163
  pages: number;
1164
1164
  lastmod: string;
1165
1165
  }[];
@@ -1202,7 +1202,7 @@ declare const ROUTER_MAP: {
1202
1202
  include?: string | number | (string | number)[] | undefined;
1203
1203
  offset?: string | number | undefined;
1204
1204
  order?: "asc" | "desc" | undefined;
1205
- orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
1205
+ orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
1206
1206
  searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
1207
1207
  slug?: string | string[] | undefined;
1208
1208
  taxRelation?: "AND" | "OR" | undefined;
@@ -1281,7 +1281,7 @@ declare const ROUTER_MAP: {
1281
1281
  include?: string | number | (string | number)[] | undefined;
1282
1282
  offset?: string | number | undefined;
1283
1283
  order?: "asc" | "desc" | undefined;
1284
- orderby?: "date" | "id" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
1284
+ orderby?: "id" | "date" | "slug" | "parent" | "title" | "author" | "include" | "relevance" | "include_slugs" | "menu_order" | undefined;
1285
1285
  searchColumns?: ("post_title" | "post_content" | "post_excerpt")[] | undefined;
1286
1286
  slug?: string | string[] | undefined;
1287
1287
  taxRelation?: "AND" | "OR" | undefined;
@@ -1430,7 +1430,7 @@ declare const ROUTER_MAP: {
1430
1430
  include?: string | number | (string | number)[] | undefined;
1431
1431
  offset?: string | number | undefined;
1432
1432
  order?: "asc" | "desc" | undefined;
1433
- orderby?: "date" | "id" | "parent" | "post" | "include" | undefined;
1433
+ orderby?: "id" | "date" | "parent" | "post" | "include" | undefined;
1434
1434
  parent?: string | number | (string | number)[] | undefined;
1435
1435
  parentExclude?: string | number | (string | number)[] | undefined;
1436
1436
  post?: string | number | (string | number)[] | undefined;
@@ -108,17 +108,17 @@ declare const Seo: z.ZodObject<{
108
108
  type Seo = z.infer<typeof Seo>;
109
109
  declare const CONTENT_TYPES: readonly ["post_type", "taxonomy", "author"];
110
110
  declare const ContentType: z.ZodEnum<{
111
- author: "author";
112
111
  post_type: "post_type";
113
112
  taxonomy: "taxonomy";
113
+ author: "author";
114
114
  }>;
115
115
  type ContentType = z.infer<typeof ContentType>;
116
116
  declare const Sitemap: z.ZodObject<{
117
117
  key: z.ZodString;
118
118
  type: z.ZodEnum<{
119
- author: "author";
120
119
  post_type: "post_type";
121
120
  taxonomy: "taxonomy";
121
+ author: "author";
122
122
  }>;
123
123
  pages: z.ZodNumber;
124
124
  lastmod: z.ZodString;
@@ -127,9 +127,9 @@ type Sitemap = z.infer<typeof Sitemap>;
127
127
  declare const SitemapList: z.ZodArray<z.ZodObject<{
128
128
  key: z.ZodString;
129
129
  type: z.ZodEnum<{
130
- author: "author";
131
130
  post_type: "post_type";
132
131
  taxonomy: "taxonomy";
132
+ author: "author";
133
133
  }>;
134
134
  pages: z.ZodNumber;
135
135
  lastmod: z.ZodString;
@@ -140,9 +140,9 @@ declare const SitemapIndex: z.ZodObject<{
140
140
  sitemaps: z.ZodArray<z.ZodObject<{
141
141
  key: z.ZodString;
142
142
  type: z.ZodEnum<{
143
- author: "author";
144
143
  post_type: "post_type";
145
144
  taxonomy: "taxonomy";
145
+ author: "author";
146
146
  }>;
147
147
  pages: z.ZodNumber;
148
148
  lastmod: z.ZodString;
@@ -174,9 +174,9 @@ declare const SitemapUrlList: z.ZodArray<z.ZodObject<{
174
174
  type SitemapUrlList = z.infer<typeof SitemapUrlList>;
175
175
  declare const ListSitemapUrlInputBase: z.ZodObject<{
176
176
  type: z.ZodEnum<{
177
- author: "author";
178
177
  post_type: "post_type";
179
178
  taxonomy: "taxonomy";
179
+ author: "author";
180
180
  }>;
181
181
  page: z.ZodOptional<z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodCoercedNumber<string | number>>>;
182
182
  }, z.core.$strip>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kizlo",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "type": "module",
5
5
  "description": "A headless WordPress framework for TypeScript.",
6
6
  "keywords": [