@variablelab/vland 0.3.8-git-bd33f50.0 → 0.3.8-git-fb21900.0

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
  // @generated by @usage-spec/commander from Commander.js metadata
2
2
  name vland
3
3
  bin vland
4
- version "0.3.8-git-bd33f50.0"
4
+ version "0.3.8-git-fb21900.0"
5
5
  usage "[options] [command]"
6
6
  flag --usage help="print KDL spec for this CLI (https://kdl.dev)"
7
7
  cmd completion help="print shell completion script (usage)" {
package/dist/run.mjs CHANGED
@@ -239,6 +239,20 @@ function rootPackageName({ template, projectName, visibility }) {
239
239
  return template === "library" ? `${LIBRARY_SCOPES[visibility ?? "public"]}/${projectName}` : projectName;
240
240
  }
241
241
  /**
242
+ * Sets `private: true` right after `version`, where package.json sorters
243
+ * (oxfmt's among them) put it, so the file passes their format check as
244
+ * generated. Mutates in place: a copy would drop the formatting pkg-types
245
+ * remembers on the object.
246
+ */
247
+ function setPrivate(packageJson) {
248
+ const keys = Object.keys(packageJson);
249
+ const moved = keys.slice(keys.indexOf("version") + 1).filter((key) => key !== "private").map((key) => [key, packageJson[key]]);
250
+ for (const [key] of moved) delete packageJson[key];
251
+ delete packageJson.private;
252
+ packageJson.private = true;
253
+ for (const [key, value] of moved) packageJson[key] = value;
254
+ }
255
+ /**
242
256
  * Writes the root `package.json`'s `name` ({@link rootPackageName}) and
243
257
  * `private` fields based on the chosen template and visibility. Uses
244
258
  * `pkg-types` so field ordering and JSON formatting survive. `private: true`
@@ -252,7 +266,7 @@ async function applyRootPackage(rootDir, options) {
252
266
  const { template, visibility } = options;
253
267
  try {
254
268
  pkg.packageJson.name = rootPackageName(options);
255
- if (template !== "library" || visibility === "private") pkg.packageJson.private = true;
269
+ if (template !== "library" || visibility === "private") setPrivate(pkg.packageJson);
256
270
  await pkg.write(pkg.packageJson);
257
271
  } catch (error) {
258
272
  debug("skipped %s", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@variablelab/vland",
3
- "version": "0.3.8-git-bd33f50.0",
3
+ "version": "0.3.8-git-fb21900.0",
4
4
  "description": "The CLI to init a new project in Variable Land",
5
5
  "homepage": "https://github.com/withvariablelab/dx/tree/main/vland/cli#readme",
6
6
  "bugs": {
@@ -35,8 +35,8 @@
35
35
  "commander": "14.0.3",
36
36
  "giget": "2.0.0",
37
37
  "nypm": "0.6.0",
38
- "@variablelab/clibuddy": "0.7.4",
39
- "@variablelab/loggy": "0.2.3"
38
+ "@variablelab/loggy": "0.2.3",
39
+ "@variablelab/clibuddy": "0.7.4"
40
40
  },
41
41
  "publishConfig": {
42
42
  "access": "public"
@@ -1,10 +1,12 @@
1
1
  import fs from "node:fs";
2
2
  import { readdir, readFile, stat, writeFile } from "node:fs/promises";
3
3
  import { extname, join } from "node:path";
4
- import { createPkg } from "@variablelab/clibuddy";
4
+ import { createPkg, type Pkg } from "@variablelab/clibuddy";
5
5
  import { logger } from "#src/services/logger.ts";
6
6
  import { LIBRARY_SCOPES, type TemplateName, type Visibility } from "./template.ts";
7
7
 
8
+ type PackageJson = Pkg["packageJson"];
9
+
8
10
  export type Placeholders = {
9
11
  projectName: string;
10
12
  author: string;
@@ -132,6 +134,24 @@ export function rootPackageName({ template, projectName, visibility }: ApplyRoot
132
134
  return template === "library" ? `${LIBRARY_SCOPES[visibility ?? "public"]}/${projectName}` : projectName;
133
135
  }
134
136
 
137
+ /**
138
+ * Sets `private: true` right after `version`, where package.json sorters
139
+ * (oxfmt's among them) put it, so the file passes their format check as
140
+ * generated. Mutates in place: a copy would drop the formatting pkg-types
141
+ * remembers on the object.
142
+ */
143
+ function setPrivate(packageJson: PackageJson): void {
144
+ const keys = Object.keys(packageJson);
145
+ const moved = keys
146
+ .slice(keys.indexOf("version") + 1)
147
+ .filter((key) => key !== "private")
148
+ .map((key) => [key, packageJson[key]] as const);
149
+ for (const [key] of moved) delete packageJson[key];
150
+ delete packageJson.private;
151
+ packageJson.private = true;
152
+ for (const [key, value] of moved) packageJson[key] = value;
153
+ }
154
+
135
155
  /**
136
156
  * Writes the root `package.json`'s `name` ({@link rootPackageName}) and
137
157
  * `private` fields based on the chosen template and visibility. Uses
@@ -150,9 +170,7 @@ export async function applyRootPackage(rootDir: string, options: ApplyRootPackag
150
170
 
151
171
  try {
152
172
  pkg.packageJson.name = rootPackageName(options);
153
- if (template !== "library" || visibility === "private") {
154
- pkg.packageJson.private = true;
155
- }
173
+ if (template !== "library" || visibility === "private") setPrivate(pkg.packageJson);
156
174
  await pkg.write(pkg.packageJson);
157
175
  } catch (error) {
158
176
  debug("skipped %s", error);