@vltpkg/init 1.0.0-rc.18 → 1.0.0-rc.22
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 +1 -1
- package/package.json +25 -21
- package/dist/get-author-from-git-user.d.ts +0 -3
- package/dist/get-author-from-git-user.d.ts.map +0 -1
- package/dist/get-author-from-git-user.js +0 -15
- package/dist/get-author-from-git-user.js.map +0 -1
- package/dist/index.d.ts +0 -22
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -41
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vltpkg/init",
|
|
3
3
|
"description": "vlt project intialization logic",
|
|
4
|
-
"version": "1.0.0-rc.
|
|
4
|
+
"version": "1.0.0-rc.22",
|
|
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":
|
|
10
|
+
"author": {
|
|
11
|
+
"name": "vlt technology inc.",
|
|
12
|
+
"email": "support@vlt.sh"
|
|
13
|
+
},
|
|
11
14
|
"dependencies": {
|
|
12
|
-
"@vltpkg/git": "1.0.0-rc.
|
|
13
|
-
"@vltpkg/
|
|
14
|
-
"@vltpkg/
|
|
15
|
-
"@vltpkg/types": "1.0.0-rc.
|
|
15
|
+
"@vltpkg/git": "1.0.0-rc.22",
|
|
16
|
+
"@vltpkg/package-json": "1.0.0-rc.22",
|
|
17
|
+
"@vltpkg/registry-client": "1.0.0-rc.22",
|
|
18
|
+
"@vltpkg/types": "1.0.0-rc.22"
|
|
16
19
|
},
|
|
17
20
|
"devDependencies": {
|
|
18
21
|
"@eslint/js": "^9.39.1",
|
|
@@ -26,33 +29,34 @@
|
|
|
26
29
|
},
|
|
27
30
|
"license": "BSD-2-Clause-Patent",
|
|
28
31
|
"engines": {
|
|
29
|
-
"node": ">=22.
|
|
32
|
+
"node": ">=22.22.0"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
36
|
+
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
37
|
+
"lint": "eslint . --fix",
|
|
38
|
+
"lint:check": "eslint .",
|
|
39
|
+
"prepack": "tsc -p tsconfig.publish.json && ../../scripts/update-dist-exports.ts",
|
|
40
|
+
"snap": "tap",
|
|
41
|
+
"test": "tap",
|
|
42
|
+
"posttest": "tsc --noEmit",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
30
44
|
},
|
|
31
45
|
"tap": {
|
|
32
46
|
"extends": "../../tap-config.yaml"
|
|
33
47
|
},
|
|
34
48
|
"prettier": "../../.prettierrc.js",
|
|
35
|
-
"module": "./
|
|
49
|
+
"module": "./src/index.ts",
|
|
36
50
|
"type": "module",
|
|
37
51
|
"exports": {
|
|
38
52
|
"./package.json": "./package.json",
|
|
39
53
|
".": {
|
|
40
54
|
"import": {
|
|
41
|
-
"default": "./
|
|
55
|
+
"default": "./src/index.ts"
|
|
42
56
|
}
|
|
43
57
|
}
|
|
44
58
|
},
|
|
45
59
|
"files": [
|
|
46
60
|
"dist"
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
"format": "prettier --write . --log-level warn --ignore-path ../../.prettierignore --cache",
|
|
50
|
-
"format:check": "prettier --check . --ignore-path ../../.prettierignore --cache",
|
|
51
|
-
"lint": "eslint . --fix",
|
|
52
|
-
"lint:check": "eslint .",
|
|
53
|
-
"snap": "tap",
|
|
54
|
-
"test": "tap",
|
|
55
|
-
"posttest": "tsc --noEmit",
|
|
56
|
-
"typecheck": "tsc --noEmit"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
61
|
+
]
|
|
62
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-author-from-git-user.d.ts","sourceRoot":"","sources":["../src/get-author-from-git-user.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAE1C,eAAO,MAAM,oBAAoB,UAAW,OAAO,KAAG,MAUrD,CAAA"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const getAuthorFromGitUser = (user) => {
|
|
2
|
-
if (!user)
|
|
3
|
-
return '';
|
|
4
|
-
const { name, email } = user;
|
|
5
|
-
let res = '';
|
|
6
|
-
if (name)
|
|
7
|
-
res += name;
|
|
8
|
-
if (email) {
|
|
9
|
-
if (name)
|
|
10
|
-
res += ' ';
|
|
11
|
-
res += `<${email}>`;
|
|
12
|
-
}
|
|
13
|
-
return res;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=get-author-from-git-user.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get-author-from-git-user.js","sourceRoot":"","sources":["../src/get-author-from-git-user.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAc,EAAU,EAAE;IAC7D,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAA;IACpB,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;IAC5B,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,IAAI,IAAI;QAAE,GAAG,IAAI,IAAI,CAAA;IACrB,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,IAAI;YAAE,GAAG,IAAI,GAAG,CAAA;QACpB,GAAG,IAAI,IAAI,KAAK,GAAG,CAAA;IACrB,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA","sourcesContent":["import type { GitUser } from '@vltpkg/git'\n\nexport const getAuthorFromGitUser = (user?: GitUser): string => {\n if (!user) return ''\n const { name, email } = user\n let res = ''\n if (name) res += name\n if (email) {\n if (name) res += ' '\n res += `<${email}>`\n }\n return res\n}\n"]}
|
package/dist/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { JSONObj } from '@vltpkg/registry-client';
|
|
2
|
-
import type { NormalizedManifest } from '@vltpkg/types';
|
|
3
|
-
import { getAuthorFromGitUser } from './get-author-from-git-user.ts';
|
|
4
|
-
export { getAuthorFromGitUser };
|
|
5
|
-
export type InitOptions = {
|
|
6
|
-
cwd?: string;
|
|
7
|
-
author?: string;
|
|
8
|
-
logger?: (...a: unknown[]) => void;
|
|
9
|
-
};
|
|
10
|
-
export type CustomizableInitOptions = {
|
|
11
|
-
name: string;
|
|
12
|
-
author: string;
|
|
13
|
-
};
|
|
14
|
-
export type JSONFileInfo<T extends JSONObj = JSONObj> = {
|
|
15
|
-
path: string;
|
|
16
|
-
data: T;
|
|
17
|
-
};
|
|
18
|
-
export type InitFileResults = {
|
|
19
|
-
manifest?: JSONFileInfo<NormalizedManifest>;
|
|
20
|
-
};
|
|
21
|
-
export declare const init: ({ cwd, author, logger, }?: InitOptions) => Promise<InitFileResults>;
|
|
22
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { getUser } from '@vltpkg/git';
|
|
2
|
-
import { PackageJson } from '@vltpkg/package-json';
|
|
3
|
-
import { basename, resolve } from 'node:path';
|
|
4
|
-
import { getAuthorFromGitUser } from "./get-author-from-git-user.js";
|
|
5
|
-
import { asError, normalizeManifest } from '@vltpkg/types';
|
|
6
|
-
export { getAuthorFromGitUser };
|
|
7
|
-
// eslint-disable-next-line no-console
|
|
8
|
-
const stderr = console.error;
|
|
9
|
-
const template = ({ name, author }) => normalizeManifest({
|
|
10
|
-
name,
|
|
11
|
-
version: '1.0.0',
|
|
12
|
-
description: '',
|
|
13
|
-
main: 'index.js',
|
|
14
|
-
...(author ? { author } : undefined),
|
|
15
|
-
});
|
|
16
|
-
export const init = async ({ cwd = process.cwd(), author, logger = stderr, } = {}) => {
|
|
17
|
-
const packageJson = new PackageJson();
|
|
18
|
-
const path = resolve(cwd, 'package.json');
|
|
19
|
-
let existingData;
|
|
20
|
-
try {
|
|
21
|
-
existingData = packageJson.read(cwd);
|
|
22
|
-
logger('package.json already exists');
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
if (asError(err).message !== 'Could not read package.json file') {
|
|
26
|
-
throw err;
|
|
27
|
-
}
|
|
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 } };
|
|
40
|
-
};
|
|
41
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"]}
|