@vltpkg/init 0.0.0-2 → 0.0.0-20

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.
package/README.md CHANGED
@@ -6,8 +6,8 @@ Project initialization logic for `vlt`.
6
6
 
7
7
  ## Overview
8
8
 
9
- This is a tool that provides the project initialization logic
10
- used by the vlt cli and gui.
9
+ This is a tool that provides the project initialization logic used by
10
+ the vlt cli and gui.
11
11
 
12
12
  ## Usage
13
13
 
@@ -1,5 +1,5 @@
1
1
  import type { JSONObj } from '@vltpkg/registry-client';
2
- import type { Manifest } from '@vltpkg/types';
2
+ import type { NormalizedManifest } from '@vltpkg/types';
3
3
  import { getAuthorFromGitUser } from './get-author-from-git-user.ts';
4
4
  export { getAuthorFromGitUser };
5
5
  export type InitOptions = {
@@ -16,7 +16,7 @@ export type JSONFileInfo<T extends JSONObj = JSONObj> = {
16
16
  data: T;
17
17
  };
18
18
  export type InitFileResults = {
19
- manifest?: JSONFileInfo<Manifest>;
19
+ manifest?: JSONFileInfo<NormalizedManifest>;
20
20
  };
21
21
  export declare const init: ({ cwd, author, logger, }?: InitOptions) => Promise<InitFileResults>;
22
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAK/B,MAAM,MAAM,WAAW,GAAG;IACxB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;CACnC,CA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AAO,MAAM,IAAI,8BAId,WAAW,KAAQ,OAAO,CAAC,eAAe,CA6B5C,CAAA"}
package/dist/esm/index.js CHANGED
@@ -2,10 +2,11 @@ import { getUser } from '@vltpkg/git';
2
2
  import { PackageJson } from '@vltpkg/package-json';
3
3
  import { basename, resolve } from 'node:path';
4
4
  import { getAuthorFromGitUser } from "./get-author-from-git-user.js";
5
+ import { asError, normalizeManifest } from '@vltpkg/types';
5
6
  export { getAuthorFromGitUser };
6
7
  // eslint-disable-next-line no-console
7
8
  const stderr = console.error;
8
- const template = ({ name, author, }) => ({
9
+ const template = ({ name, author }) => normalizeManifest({
9
10
  name,
10
11
  version: '1.0.0',
11
12
  description: '',
@@ -15,26 +16,26 @@ const template = ({ name, author, }) => ({
15
16
  export const init = async ({ cwd = process.cwd(), author, logger = stderr, } = {}) => {
16
17
  const packageJson = new PackageJson();
17
18
  const path = resolve(cwd, 'package.json');
19
+ let existingData;
18
20
  try {
19
- packageJson.read(cwd);
20
- // will only return here in case the package.json file does not exist
21
+ existingData = packageJson.read(cwd);
21
22
  logger('package.json already exists');
22
- return {};
23
23
  }
24
- catch (e) {
25
- const err = e;
26
- if (!!e && err.message !== 'Could not read package.json file') {
24
+ catch (err) {
25
+ if (asError(err).message !== 'Could not read package.json file') {
27
26
  throw err;
28
27
  }
29
- const name = basename(cwd);
30
- const data = template({
31
- name,
32
- author: author ??
33
- getAuthorFromGitUser(await getUser().catch(() => undefined)),
34
- });
35
- const indent = 2;
36
- packageJson.write(cwd, data, indent);
37
- return { manifest: { path, data } };
38
28
  }
29
+ const name = basename(cwd);
30
+ const templateData = template({
31
+ name,
32
+ author: author ??
33
+ getAuthorFromGitUser(await getUser().catch(() => undefined)),
34
+ });
35
+ // Merge template with existing data, preserving existing properties
36
+ const data = existingData ? { ...templateData, ...existingData } : templateData;
37
+ const indent = 2;
38
+ packageJson.write(cwd, data, indent);
39
+ return { manifest: { path, data } };
39
40
  };
40
41
  //# sourceMappingURL=index.js.map
@@ -1 +1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MAAM,GAAG,CAAA;QACX,CAAC;QAED,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;QAC1B,MAAM,IAAI,GAAG,QAAQ,CAAC;YACpB,IAAI;YACJ,MAAM,EACJ,MAAM;gBACN,oBAAoB,CAAC,MAAM,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;SAC/D,CAAC,CAAA;QACF,MAAM,MAAM,GAAG,CAAC,CAAA;QAChB,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;QACpC,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAA;IACrC,CAAC;AACH,CAAC,CAAA","sourcesContent":["import { getUser } from '@vltpkg/git'\nimport { PackageJson } from '@vltpkg/package-json'\nimport type { JSONObj } from '@vltpkg/registry-client'\nimport type { Manifest } from '@vltpkg/types'\nimport { basename, resolve } from 'node:path'\nimport { getAuthorFromGitUser } from './get-author-from-git-user.ts'\nexport { getAuthorFromGitUser }\n\n// eslint-disable-next-line no-console\nconst stderr: (...a: unknown[]) => void = console.error\n\nexport type InitOptions = {\n cwd?: string\n author?: string\n logger?: (...a: unknown[]) => void\n}\n\nexport type CustomizableInitOptions = {\n name: string\n author: string\n}\n\nconst template = ({\n name,\n author,\n}: CustomizableInitOptions): Manifest => ({\n name,\n version: '1.0.0',\n description: '',\n main: 'index.js',\n ...(author ? { author } : undefined),\n})\n\nexport type JSONFileInfo<T extends JSONObj = JSONObj> = {\n path: string\n data: T\n}\n\nexport type InitFileResults = {\n manifest?: JSONFileInfo<Manifest>\n // TODO: enable these if/when we do more than just the manifest\n // Eg:\n // workspaces?: JSONFileInfo\n // config?: JSONFileInfo\n}\n\nexport const init = async ({\n cwd = process.cwd(),\n author,\n logger = stderr,\n}: InitOptions = {}): Promise<InitFileResults> => {\n const packageJson = new PackageJson()\n const path = resolve(cwd, 'package.json')\n try {\n packageJson.read(cwd)\n // will only return here in case the package.json file does not exist\n logger('package.json already exists')\n return {}\n } catch (e) {\n const err = e as Error\n if (!!e && err.message !== 'Could not read package.json file') {\n throw err\n }\n\n const name = basename(cwd)\n const data = template({\n name,\n author:\n author ??\n getAuthorFromGitUser(await getUser().catch(() => undefined)),\n })\n const indent = 2\n packageJson.write(cwd, data, indent)\n return { manifest: { path, data } }\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAGlD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AACpE,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,CAAA;AAE/B,sCAAsC;AACtC,MAAM,MAAM,GAA8B,OAAO,CAAC,KAAK,CAAA;AAavD,MAAM,QAAQ,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,EAA2B,EAAE,EAAE,CAC7D,iBAAiB,CAAC;IAChB,IAAI;IACJ,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,EAAE;IACf,IAAI,EAAE,UAAU;IAChB,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;CACrC,CAAC,CAAA;AAeJ,MAAM,CAAC,MAAM,IAAI,GAAG,KAAK,EAAE,EACzB,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,EACnB,MAAM,EACN,MAAM,GAAG,MAAM,MACA,EAAE,EAA4B,EAAE;IAC/C,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAA;IACrC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;IACzC,IAAI,YAA4C,CAAA;IAEhD,IAAI,CAAC;QACH,YAAY,GAAG,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACpC,MAAM,CAAC,6BAA6B,CAAC,CAAA;IACvC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,KAAK,kCAAkC,EAAE,CAAC;YAChE,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAA;IAC1B,MAAM,YAAY,GAAG,QAAQ,CAAC;QAC5B,IAAI;QACJ,MAAM,EACJ,MAAM;YACN,oBAAoB,CAAC,MAAM,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;KAC/D,CAAC,CAAA;IAEF,oEAAoE;IACpE,MAAM,IAAI,GACR,YAAY,CAAC,CAAC,CAAC,EAAE,GAAG,YAAY,EAAE,GAAG,YAAY,EAAE,CAAC,CAAC,CAAC,YAAY,CAAA;IAEpE,MAAM,MAAM,GAAG,CAAC,CAAA;IAChB,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAA;IACpC,OAAO,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAA;AACrC,CAAC,CAAA","sourcesContent":["import { getUser } from '@vltpkg/git'\nimport { PackageJson } from '@vltpkg/package-json'\nimport type { JSONObj } from '@vltpkg/registry-client'\nimport type { NormalizedManifest } from '@vltpkg/types'\nimport { basename, resolve } from 'node:path'\nimport { getAuthorFromGitUser } from './get-author-from-git-user.ts'\nimport { asError, normalizeManifest } from '@vltpkg/types'\nexport { getAuthorFromGitUser }\n\n// eslint-disable-next-line no-console\nconst stderr: (...a: unknown[]) => void = console.error\n\nexport type InitOptions = {\n cwd?: string\n author?: string\n logger?: (...a: unknown[]) => void\n}\n\nexport type CustomizableInitOptions = {\n name: string\n author: string\n}\n\nconst template = ({ name, author }: CustomizableInitOptions) =>\n normalizeManifest({\n name,\n version: '1.0.0',\n description: '',\n main: 'index.js',\n ...(author ? { author } : undefined),\n })\n\nexport type JSONFileInfo<T extends JSONObj = JSONObj> = {\n path: string\n data: T\n}\n\nexport type InitFileResults = {\n manifest?: JSONFileInfo<NormalizedManifest>\n // TODO: enable these if/when we do more than just the manifest\n // Eg:\n // workspaces?: JSONFileInfo\n // config?: JSONFileInfo\n}\n\nexport const init = async ({\n cwd = process.cwd(),\n author,\n logger = stderr,\n}: InitOptions = {}): Promise<InitFileResults> => {\n const packageJson = new PackageJson()\n const path = resolve(cwd, 'package.json')\n let existingData: NormalizedManifest | undefined\n\n try {\n existingData = packageJson.read(cwd)\n logger('package.json already exists')\n } catch (err) {\n if (asError(err).message !== 'Could not read package.json file') {\n throw err\n }\n }\n\n const name = basename(cwd)\n const templateData = template({\n name,\n author:\n author ??\n getAuthorFromGitUser(await getUser().catch(() => undefined)),\n })\n\n // Merge template with existing data, preserving existing properties\n const data: NormalizedManifest =\n existingData ? { ...templateData, ...existingData } : templateData\n\n const indent = 2\n packageJson.write(cwd, data, indent)\n return { manifest: { path, data } }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/init",
3
3
  "description": "vlt project intialization logic",
4
- "version": "0.0.0-2",
4
+ "version": "0.0.0-20",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -19,24 +19,21 @@
19
19
  }
20
20
  },
21
21
  "dependencies": {
22
- "@vltpkg/error-cause": "0.0.0-2",
23
- "@vltpkg/package-json": "0.0.0-2",
24
- "@vltpkg/registry-client": "0.0.0-2",
25
- "@vltpkg/xdg": "0.0.0-2",
26
- "@vltpkg/git": "0.0.0-2",
27
- "@vltpkg/types": "0.0.0-2"
22
+ "@vltpkg/git": "0.0.0-20",
23
+ "@vltpkg/registry-client": "0.0.0-20",
24
+ "@vltpkg/types": "0.0.0-20",
25
+ "@vltpkg/package-json": "0.0.0-20"
28
26
  },
29
27
  "devDependencies": {
30
- "@eslint/js": "^9.20.0",
31
- "@types/eslint__js": "^8.42.3",
32
- "@types/node": "^22.13.1",
33
- "eslint": "^9.20.0",
34
- "prettier": "^3.4.2",
28
+ "@eslint/js": "^9.28.0",
29
+ "@types/node": "^22.15.29",
30
+ "eslint": "^9.28.0",
31
+ "prettier": "^3.6.0",
35
32
  "tap": "^21.1.0",
36
33
  "tshy": "^3.0.2",
37
- "typedoc": "0.27.6",
34
+ "typedoc": "~0.27.9",
38
35
  "typescript": "5.7.3",
39
- "typescript-eslint": "^8.23.0"
36
+ "typescript-eslint": "^8.33.1"
40
37
  },
41
38
  "license": "BSD-2-Clause-Patent",
42
39
  "engines": {
@@ -68,6 +65,7 @@
68
65
  "snap": "tap",
69
66
  "test": "tap",
70
67
  "posttest": "tsc --noEmit",
68
+ "tshy": "tshy",
71
69
  "typecheck": "tsc --noEmit"
72
70
  }
73
71
  }