@vltpkg/init 0.0.0-9 → 1.0.0-rc.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,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;AAEpE,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,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAaD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,CAAC,CAAA;CACR,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAA;CAKlC,CAAA;AAED,eAAO,MAAM,IAAI,8BAId,WAAW,KAAQ,OAAO,CAAC,eAAe,CAwB5C,CAAA"}
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,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAEpE,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,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAWD,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,IAAI;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,CAAC,CAAA;CACR,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,EAAE,YAAY,CAAC,kBAAkB,CAAC,CAAA;CAK5C,CAAA;AAED,eAAO,MAAM,IAAI,8BAId,WAAW,KAAQ,OAAO,CAAC,eAAe,CA6B5C,CAAA"}
package/dist/esm/index.js CHANGED
@@ -2,11 +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 } from '@vltpkg/error-cause';
5
+ import { asError, normalizeManifest } from '@vltpkg/types';
6
6
  export { getAuthorFromGitUser };
7
7
  // eslint-disable-next-line no-console
8
8
  const stderr = console.error;
9
- const template = ({ name, author, }) => ({
9
+ const template = ({ name, author }) => normalizeManifest({
10
10
  name,
11
11
  version: '1.0.0',
12
12
  description: '',
@@ -16,25 +16,26 @@ const template = ({ name, author, }) => ({
16
16
  export const init = async ({ cwd = process.cwd(), author, logger = stderr, } = {}) => {
17
17
  const packageJson = new PackageJson();
18
18
  const path = resolve(cwd, 'package.json');
19
+ let existingData;
19
20
  try {
20
- packageJson.read(cwd);
21
- // will only return here in case the package.json file does not exist
21
+ existingData = packageJson.read(cwd);
22
22
  logger('package.json already exists');
23
- return {};
24
23
  }
25
24
  catch (err) {
26
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 @@
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,MAA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AK,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'\nimport { asError } from '@vltpkg/error-cause'\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 (err) {\n if (asError(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,12 +1,13 @@
1
1
  {
2
2
  "name": "@vltpkg/init",
3
3
  "description": "vlt project intialization logic",
4
- "version": "0.0.0-9",
4
+ "version": "1.0.0-rc.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
8
8
  "directory": "src/init"
9
9
  },
10
+ "author": "vlt technology inc. <support@vlt.sh> (http://vlt.sh)",
10
11
  "tshy": {
11
12
  "selfLink": false,
12
13
  "liveDev": true,
@@ -19,23 +20,21 @@
19
20
  }
20
21
  },
21
22
  "dependencies": {
22
- "@vltpkg/error-cause": "0.0.0-9",
23
- "@vltpkg/git": "0.0.0-9",
24
- "@vltpkg/package-json": "0.0.0-9",
25
- "@vltpkg/types": "0.0.0-9",
26
- "@vltpkg/registry-client": "0.0.0-9"
23
+ "@vltpkg/git": "1.0.0-rc.2",
24
+ "@vltpkg/types": "1.0.0-rc.2",
25
+ "@vltpkg/package-json": "1.0.0-rc.2",
26
+ "@vltpkg/registry-client": "1.0.0-rc.2"
27
27
  },
28
28
  "devDependencies": {
29
- "@eslint/js": "^9.20.0",
30
- "@types/eslint__js": "^8.42.3",
31
- "@types/node": "^22.13.1",
32
- "eslint": "^9.20.0",
33
- "prettier": "^3.4.2",
29
+ "@eslint/js": "^9.34.0",
30
+ "@types/node": "^22.17.2",
31
+ "eslint": "^9.34.0",
32
+ "prettier": "^3.6.2",
34
33
  "tap": "^21.1.0",
35
34
  "tshy": "^3.0.2",
36
- "typedoc": "0.27.6",
35
+ "typedoc": "~0.27.9",
37
36
  "typescript": "5.7.3",
38
- "typescript-eslint": "^8.23.0"
37
+ "typescript-eslint": "^8.40.0"
39
38
  },
40
39
  "license": "BSD-2-Clause-Patent",
41
40
  "engines": {
@@ -67,6 +66,7 @@
67
66
  "snap": "tap",
68
67
  "test": "tap",
69
68
  "posttest": "tsc --noEmit",
69
+ "tshy": "tshy",
70
70
  "typecheck": "tsc --noEmit"
71
71
  }
72
72
  }