create-typescript-app 0.1.1 → 1.29.14
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/LICENSE.md +17 -5
- package/README.md +118 -0
- package/bin/index.js +4 -0
- package/lib/bin/index.d.ts +3 -0
- package/lib/bin/index.js +52 -0
- package/lib/bin/index.js.map +1 -0
- package/lib/bin/mode.d.ts +4 -0
- package/lib/bin/mode.js +43 -0
- package/lib/bin/mode.js.map +1 -0
- package/lib/create/createRerunSuggestion.d.ts +6 -0
- package/lib/create/createRerunSuggestion.js +17 -0
- package/lib/create/createRerunSuggestion.js.map +1 -0
- package/lib/create/createWithOptions.d.ts +9 -0
- package/lib/create/createWithOptions.js +62 -0
- package/lib/create/createWithOptions.js.map +1 -0
- package/lib/create/index.d.ts +3 -0
- package/lib/create/index.js +64 -0
- package/lib/create/index.js.map +1 -0
- package/lib/greet.d.ts +5 -0
- package/lib/greet.js +14 -0
- package/lib/greet.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/initialize/index.d.ts +3 -0
- package/lib/initialize/index.js +32 -0
- package/lib/initialize/index.js.map +1 -0
- package/lib/initialize/initializeWithOptions.d.ts +7 -0
- package/lib/initialize/initializeWithOptions.js +60 -0
- package/lib/initialize/initializeWithOptions.js.map +1 -0
- package/lib/migrate/index.d.ts +3 -0
- package/lib/migrate/index.js +29 -0
- package/lib/migrate/index.js.map +1 -0
- package/lib/migrate/migrateWithOptions.d.ts +7 -0
- package/lib/migrate/migrateWithOptions.js +67 -0
- package/lib/migrate/migrateWithOptions.js.map +1 -0
- package/lib/shared/cli/lines.d.ts +5 -0
- package/lib/shared/cli/lines.js +17 -0
- package/lib/shared/cli/lines.js.map +1 -0
- package/lib/shared/cli/lowerFirst.d.ts +3 -0
- package/lib/shared/cli/lowerFirst.js +7 -0
- package/lib/shared/cli/lowerFirst.js.map +1 -0
- package/lib/shared/cli/outro.d.ts +7 -0
- package/lib/shared/cli/outro.js +21 -0
- package/lib/shared/cli/outro.js.map +1 -0
- package/lib/shared/cli/spinners.d.ts +6 -0
- package/lib/shared/cli/spinners.js +49 -0
- package/lib/shared/cli/spinners.js.map +1 -0
- package/lib/shared/cli/startLineWithDots.d.ts +3 -0
- package/lib/shared/cli/startLineWithDots.js +31 -0
- package/lib/shared/cli/startLineWithDots.js.map +1 -0
- package/lib/shared/doesRepositoryExist.d.ts +9 -0
- package/lib/shared/doesRepositoryExist.js +18 -0
- package/lib/shared/doesRepositoryExist.js.map +1 -0
- package/lib/shared/ensureGitRepository.d.ts +3 -0
- package/lib/shared/ensureGitRepository.js +12 -0
- package/lib/shared/ensureGitRepository.js.map +1 -0
- package/lib/shared/getGitHubUserAsAllContributor.d.ts +3 -0
- package/lib/shared/getGitHubUserAsAllContributor.js +31 -0
- package/lib/shared/getGitHubUserAsAllContributor.js.map +1 -0
- package/lib/shared/options/args.d.ts +85 -0
- package/lib/shared/options/args.js +33 -0
- package/lib/shared/options/args.js.map +1 -0
- package/lib/shared/options/augmentOptionsWithExcludes.d.ts +5 -0
- package/lib/shared/options/augmentOptionsWithExcludes.js +126 -0
- package/lib/shared/options/augmentOptionsWithExcludes.js.map +1 -0
- package/lib/shared/options/ensureRepositoryExists.d.ts +11 -0
- package/lib/shared/options/ensureRepositoryExists.js +58 -0
- package/lib/shared/options/ensureRepositoryExists.js.map +1 -0
- package/lib/shared/options/getOctokit.d.ts +5 -0
- package/lib/shared/options/getOctokit.js +17 -0
- package/lib/shared/options/getOctokit.js.map +1 -0
- package/lib/shared/options/getPrefillOrPromptedOption.d.ts +3 -0
- package/lib/shared/options/getPrefillOrPromptedOption.js +23 -0
- package/lib/shared/options/getPrefillOrPromptedOption.js.map +1 -0
- package/lib/shared/options/optionalDefault.d.ts +3 -0
- package/lib/shared/options/optionalDefault.js +13 -0
- package/lib/shared/options/optionalDefault.js.map +1 -0
- package/lib/shared/options/readGitAndNpmDefaults/index.d.ts +11 -0
- package/lib/shared/options/readGitAndNpmDefaults/index.js +36 -0
- package/lib/shared/options/readGitAndNpmDefaults/index.js.map +1 -0
- package/lib/shared/options/readGitAndNpmDefaults/parsePackageAuthor.d.ts +8 -0
- package/lib/shared/options/readGitAndNpmDefaults/parsePackageAuthor.js +14 -0
- package/lib/shared/options/readGitAndNpmDefaults/parsePackageAuthor.js.map +1 -0
- package/lib/shared/options/readGitAndNpmDefaults/readTitleFromReadme.d.ts +3 -0
- package/lib/shared/options/readGitAndNpmDefaults/readTitleFromReadme.js +8 -0
- package/lib/shared/options/readGitAndNpmDefaults/readTitleFromReadme.js.map +1 -0
- package/lib/shared/options/readOptions.d.ts +10 -0
- package/lib/shared/options/readOptions.js +83 -0
- package/lib/shared/options/readOptions.js.map +1 -0
- package/lib/shared/packages.d.ts +6 -0
- package/lib/shared/packages.js +20 -0
- package/lib/shared/packages.js.map +1 -0
- package/lib/shared/prompts.d.ts +4 -0
- package/lib/shared/prompts.js +16 -0
- package/lib/shared/prompts.js.map +1 -0
- package/lib/shared/readFileAsJson.d.ts +3 -0
- package/lib/shared/readFileAsJson.js +15 -0
- package/lib/shared/readFileAsJson.js.map +1 -0
- package/lib/shared/readFileSafe.d.ts +3 -0
- package/lib/shared/readFileSafe.js +12 -0
- package/lib/shared/readFileSafe.js.map +1 -0
- package/lib/shared/readFileSafeAsJson.d.ts +3 -0
- package/lib/shared/readFileSafeAsJson.js +8 -0
- package/lib/shared/readFileSafeAsJson.js.map +1 -0
- package/lib/shared/runOrRestore.d.ts +7 -0
- package/lib/shared/runOrRestore.js +41 -0
- package/lib/shared/runOrRestore.js.map +1 -0
- package/lib/shared/tryCatchAsync.d.ts +3 -0
- package/lib/shared/tryCatchAsync.js +11 -0
- package/lib/shared/tryCatchAsync.js.map +1 -0
- package/lib/shared/types.d.ts +54 -0
- package/lib/shared/types.js +1 -0
- package/lib/shared/types.js.map +1 -0
- package/lib/steps/addOwnerAsAllContributor.d.ts +3 -0
- package/lib/steps/addOwnerAsAllContributor.js +41 -0
- package/lib/steps/addOwnerAsAllContributor.js.map +1 -0
- package/lib/steps/addToolAllContributors.d.ts +3 -0
- package/lib/steps/addToolAllContributors.js +12 -0
- package/lib/steps/addToolAllContributors.js.map +1 -0
- package/lib/steps/clearChangelog.d.ts +3 -0
- package/lib/steps/clearChangelog.js +12 -0
- package/lib/steps/clearChangelog.js.map +1 -0
- package/lib/steps/clearUnnecessaryFiles.d.ts +3 -0
- package/lib/steps/clearUnnecessaryFiles.js +33 -0
- package/lib/steps/clearUnnecessaryFiles.js.map +1 -0
- package/lib/steps/detectExistingContributors.d.ts +3 -0
- package/lib/steps/detectExistingContributors.js +16 -0
- package/lib/steps/detectExistingContributors.js.map +1 -0
- package/lib/steps/finalizeDependencies.d.ts +5 -0
- package/lib/steps/finalizeDependencies.js +59 -0
- package/lib/steps/finalizeDependencies.js.map +1 -0
- package/lib/steps/initializeGitHubRepository/index.d.ts +6 -0
- package/lib/steps/initializeGitHubRepository/index.js +14 -0
- package/lib/steps/initializeGitHubRepository/index.js.map +1 -0
- package/lib/steps/initializeGitHubRepository/initializeBranchProtectionSettings.d.ts +6 -0
- package/lib/steps/initializeGitHubRepository/initializeBranchProtectionSettings.js +46 -0
- package/lib/steps/initializeGitHubRepository/initializeBranchProtectionSettings.js.map +1 -0
- package/lib/steps/initializeGitHubRepository/labels/getExistingEquivalentLabel.d.ts +3 -0
- package/lib/steps/initializeGitHubRepository/labels/getExistingEquivalentLabel.js +14 -0
- package/lib/steps/initializeGitHubRepository/labels/getExistingEquivalentLabel.js.map +1 -0
- package/lib/steps/initializeGitHubRepository/labels/initializeRepositoryLabels.d.ts +3 -0
- package/lib/steps/initializeGitHubRepository/labels/initializeRepositoryLabels.js +31 -0
- package/lib/steps/initializeGitHubRepository/labels/initializeRepositoryLabels.js.map +1 -0
- package/lib/steps/initializeGitHubRepository/labels/outcomeLabels.d.ts +7 -0
- package/lib/steps/initializeGitHubRepository/labels/outcomeLabels.js +86 -0
- package/lib/steps/initializeGitHubRepository/labels/outcomeLabels.js.map +1 -0
- package/lib/steps/initializeGitRemote.d.ts +6 -0
- package/lib/steps/initializeGitRemote.js +15 -0
- package/lib/steps/initializeGitRemote.js.map +1 -0
- package/lib/steps/initializeRepositorySettings.d.ts +7 -0
- package/lib/steps/initializeRepositorySettings.js +27 -0
- package/lib/steps/initializeRepositorySettings.js.map +1 -0
- package/lib/steps/removeSetupScripts.d.ts +3 -0
- package/lib/steps/removeSetupScripts.js +23 -0
- package/lib/steps/removeSetupScripts.js.map +1 -0
- package/lib/steps/resetGitTags.d.ts +3 -0
- package/lib/steps/resetGitTags.js +12 -0
- package/lib/steps/resetGitTags.js.map +1 -0
- package/lib/steps/runCommands.d.ts +3 -0
- package/lib/steps/runCommands.js +33 -0
- package/lib/steps/runCommands.js.map +1 -0
- package/lib/steps/uninstallPackages.d.ts +3 -0
- package/lib/steps/uninstallPackages.js +41 -0
- package/lib/steps/uninstallPackages.js.map +1 -0
- package/lib/steps/updateAllContributorsTable.d.ts +5 -0
- package/lib/steps/updateAllContributorsTable.js +27 -0
- package/lib/steps/updateAllContributorsTable.js.map +1 -0
- package/lib/steps/updateLocalFiles.d.ts +5 -0
- package/lib/steps/updateLocalFiles.js +58 -0
- package/lib/steps/updateLocalFiles.js.map +1 -0
- package/lib/steps/updateReadme.d.ts +4 -0
- package/lib/steps/updateReadme.js +17 -0
- package/lib/steps/updateReadme.js.map +1 -0
- package/lib/steps/writeReadme.d.ts +5 -0
- package/lib/steps/writeReadme.js +87 -0
- package/lib/steps/writeReadme.js.map +1 -0
- package/lib/steps/writing/creation/createESLintRC.d.ts +5 -0
- package/lib/steps/writing/creation/createESLintRC.js +163 -0
- package/lib/steps/writing/creation/createESLintRC.js.map +1 -0
- package/lib/steps/writing/creation/dotGitHub/actions.d.ts +7 -0
- package/lib/steps/writing/creation/dotGitHub/actions.js +29 -0
- package/lib/steps/writing/creation/dotGitHub/actions.js.map +1 -0
- package/lib/steps/writing/creation/dotGitHub/createDevelopment.d.ts +5 -0
- package/lib/steps/writing/creation/dotGitHub/createDevelopment.js +96 -0
- package/lib/steps/writing/creation/dotGitHub/createDevelopment.js.map +1 -0
- package/lib/steps/writing/creation/dotGitHub/createDotGitHubFiles.d.ts +14 -0
- package/lib/steps/writing/creation/dotGitHub/createDotGitHubFiles.js +282 -0
- package/lib/steps/writing/creation/dotGitHub/createDotGitHubFiles.js.map +1 -0
- package/lib/steps/writing/creation/dotGitHub/createWorkflowFile.d.ts +49 -0
- package/lib/steps/writing/creation/dotGitHub/createWorkflowFile.js +34 -0
- package/lib/steps/writing/creation/dotGitHub/createWorkflowFile.js.map +1 -0
- package/lib/steps/writing/creation/dotGitHub/index.d.ts +41 -0
- package/lib/steps/writing/creation/dotGitHub/index.js +16 -0
- package/lib/steps/writing/creation/dotGitHub/index.js.map +1 -0
- package/lib/steps/writing/creation/dotGitHub/issueTemplate.d.ts +10 -0
- package/lib/steps/writing/creation/dotGitHub/issueTemplate.js +202 -0
- package/lib/steps/writing/creation/dotGitHub/issueTemplate.js.map +1 -0
- package/lib/steps/writing/creation/dotGitHub/workflows.d.ts +20 -0
- package/lib/steps/writing/creation/dotGitHub/workflows.js +280 -0
- package/lib/steps/writing/creation/dotGitHub/workflows.js.map +1 -0
- package/lib/steps/writing/creation/dotHusky.d.ts +6 -0
- package/lib/steps/writing/creation/dotHusky.js +15 -0
- package/lib/steps/writing/creation/dotHusky.js.map +1 -0
- package/lib/steps/writing/creation/dotVSCode.d.ts +9 -0
- package/lib/steps/writing/creation/dotVSCode.js +55 -0
- package/lib/steps/writing/creation/dotVSCode.js.map +1 -0
- package/lib/steps/writing/creation/formatters/formatIgnoreFile.d.ts +3 -0
- package/lib/steps/writing/creation/formatters/formatIgnoreFile.js +7 -0
- package/lib/steps/writing/creation/formatters/formatIgnoreFile.js.map +1 -0
- package/lib/steps/writing/creation/formatters/formatJson.d.ts +3 -0
- package/lib/steps/writing/creation/formatters/formatJson.js +17 -0
- package/lib/steps/writing/creation/formatters/formatJson.js.map +1 -0
- package/lib/steps/writing/creation/formatters/formatTypeScript.d.ts +3 -0
- package/lib/steps/writing/creation/formatters/formatTypeScript.js +8 -0
- package/lib/steps/writing/creation/formatters/formatTypeScript.js.map +1 -0
- package/lib/steps/writing/creation/formatters/formatYaml.d.ts +3 -0
- package/lib/steps/writing/creation/formatters/formatYaml.js +23 -0
- package/lib/steps/writing/creation/formatters/formatYaml.js.map +1 -0
- package/lib/steps/writing/creation/index.d.ts +6 -0
- package/lib/steps/writing/creation/index.js +18 -0
- package/lib/steps/writing/creation/index.js.map +1 -0
- package/lib/steps/writing/creation/rootFiles.d.ts +25 -0
- package/lib/steps/writing/creation/rootFiles.js +202 -0
- package/lib/steps/writing/creation/rootFiles.js.map +1 -0
- package/lib/steps/writing/creation/src.d.ts +10 -0
- package/lib/steps/writing/creation/src.js +90 -0
- package/lib/steps/writing/creation/src.js.map +1 -0
- package/lib/steps/writing/creation/writeAllContributorsRC.d.ts +5 -0
- package/lib/steps/writing/creation/writeAllContributorsRC.js +25 -0
- package/lib/steps/writing/creation/writeAllContributorsRC.js.map +1 -0
- package/lib/steps/writing/creation/writePackageJson.d.ts +5 -0
- package/lib/steps/writing/creation/writePackageJson.js +98 -0
- package/lib/steps/writing/creation/writePackageJson.js.map +1 -0
- package/lib/steps/writing/types.d.ts +5 -0
- package/lib/steps/writing/types.js +1 -0
- package/lib/steps/writing/types.js.map +1 -0
- package/lib/steps/writing/writeStructure.d.ts +5 -0
- package/lib/steps/writing/writeStructure.js +11 -0
- package/lib/steps/writing/writeStructure.js.map +1 -0
- package/lib/steps/writing/writeStructureWorker.d.ts +5 -0
- package/lib/steps/writing/writeStructureWorker.js +47 -0
- package/lib/steps/writing/writeStructureWorker.js.map +1 -0
- package/lib/types.d.ts +7 -0
- package/lib/types.js +1 -0
- package/lib/types.js.map +1 -0
- package/package.json +112 -23
- package/.vscode/settings.json +0 -3
- package/dist/src/cli.d.ts +0 -0
- package/dist/src/cli.js +0 -2
- package/dist/src/cli.js.map +0 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.js +0 -53
- package/dist/src/index.js.map +0 -1
- package/dist/template/src/cli.d.ts +0 -0
- package/dist/template/src/cli.js +0 -2
- package/dist/template/src/cli.js.map +0 -1
- package/dist/template/src/index.d.ts +0 -0
- package/dist/template/src/index.js +0 -2
- package/dist/template/src/index.js.map +0 -1
- package/src/cli.ts +0 -0
- package/src/index.ts +0 -56
- package/src/types.d.ts +0 -10
- package/template/.vscode/settings.json +0 -3
- package/template/README.md +0 -28
- package/template/package.json +0 -34
- package/template/src/cli.ts +0 -0
- package/template/src/index.ts +0 -0
- package/template/tsconfig.json +0 -15
- package/template/tslint.json +0 -48
- package/tsconfig.json +0 -15
- package/tslint.json +0 -48
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { createESLintRC } from "./createESLintRC.js";
|
|
2
|
+
import { formatIgnoreFile } from "./formatters/formatIgnoreFile.js";
|
|
3
|
+
import { formatJson } from "./formatters/formatJson.js";
|
|
4
|
+
import { formatTypeScript } from "./formatters/formatTypeScript.js";
|
|
5
|
+
import { writeAllContributorsRC } from "./writeAllContributorsRC.js";
|
|
6
|
+
import { writePackageJson } from "./writePackageJson.js";
|
|
7
|
+
async function createRootFiles(options) {
|
|
8
|
+
return {
|
|
9
|
+
".all-contributorsrc": await writeAllContributorsRC(options),
|
|
10
|
+
".eslintignore": formatIgnoreFile(
|
|
11
|
+
[
|
|
12
|
+
"!.*",
|
|
13
|
+
...options.excludeTests ? [] : ["coverage*"],
|
|
14
|
+
"lib",
|
|
15
|
+
"node_modules",
|
|
16
|
+
"pnpm-lock.yaml"
|
|
17
|
+
].filter(Boolean)
|
|
18
|
+
),
|
|
19
|
+
".eslintrc.cjs": await createESLintRC(options),
|
|
20
|
+
".gitignore": formatIgnoreFile([
|
|
21
|
+
...options.excludeTests ? [] : ["coverage*/"],
|
|
22
|
+
"lib/",
|
|
23
|
+
"node_modules/"
|
|
24
|
+
]),
|
|
25
|
+
...!options.excludeLintMd && {
|
|
26
|
+
".markdownlint.json": await formatJson({
|
|
27
|
+
extends: "markdownlint/style/prettier",
|
|
28
|
+
"first-line-h1": false,
|
|
29
|
+
"no-inline-html": false
|
|
30
|
+
}),
|
|
31
|
+
".markdownlintignore": formatIgnoreFile([
|
|
32
|
+
".github/CODE_OF_CONDUCT.md",
|
|
33
|
+
"CHANGELOG.md",
|
|
34
|
+
"lib/",
|
|
35
|
+
"node_modules/"
|
|
36
|
+
])
|
|
37
|
+
},
|
|
38
|
+
...!options.excludeLintPackageJson && {
|
|
39
|
+
".npmpackagejsonlintrc.json": await formatJson({
|
|
40
|
+
extends: "npm-package-json-lint-config-default",
|
|
41
|
+
rules: {
|
|
42
|
+
"require-description": "error",
|
|
43
|
+
"require-license": "error"
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
},
|
|
47
|
+
".nvmrc": `18.17.1
|
|
48
|
+
`,
|
|
49
|
+
".prettierignore": formatIgnoreFile([
|
|
50
|
+
...options.excludeTests ? [] : ["coverage*/"],
|
|
51
|
+
"lib/",
|
|
52
|
+
"pnpm-lock.yaml",
|
|
53
|
+
"",
|
|
54
|
+
"# See https://github.com/all-contributors/cli/issues/347",
|
|
55
|
+
".all-contributorsrc"
|
|
56
|
+
]),
|
|
57
|
+
".prettierrc": await formatJson({
|
|
58
|
+
$schema: "http://json.schemastore.org/prettierrc",
|
|
59
|
+
overrides: [
|
|
60
|
+
{
|
|
61
|
+
files: ".*rc",
|
|
62
|
+
options: { parser: "json" }
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
files: ".nvmrc",
|
|
66
|
+
options: { parser: "yaml" }
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
plugins: ["prettier-plugin-curly", "prettier-plugin-packagejson"],
|
|
70
|
+
useTabs: true
|
|
71
|
+
}),
|
|
72
|
+
...!options.excludeReleases && {
|
|
73
|
+
".release-it.json": await formatJson({
|
|
74
|
+
git: {
|
|
75
|
+
commitMessage: "chore: release v${version}",
|
|
76
|
+
requireCommits: true
|
|
77
|
+
},
|
|
78
|
+
github: {
|
|
79
|
+
autoGenerate: true,
|
|
80
|
+
release: true,
|
|
81
|
+
releaseName: "v${version}"
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
},
|
|
85
|
+
"LICENSE.md": `# MIT License
|
|
86
|
+
|
|
87
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
88
|
+
a copy of this software and associated documentation files (the
|
|
89
|
+
'Software'), to deal in the Software without restriction, including
|
|
90
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
91
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
92
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
93
|
+
the following conditions:
|
|
94
|
+
|
|
95
|
+
The above copyright notice and this permission notice shall be
|
|
96
|
+
included in all copies or substantial portions of the Software.
|
|
97
|
+
|
|
98
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
99
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
100
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
101
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
102
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
103
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
104
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
105
|
+
`,
|
|
106
|
+
...!options.excludeLintSpelling && {
|
|
107
|
+
"cspell.json": await formatJson({
|
|
108
|
+
dictionaries: ["typescript"],
|
|
109
|
+
ignorePaths: [
|
|
110
|
+
".github",
|
|
111
|
+
"CHANGELOG.md",
|
|
112
|
+
...options.excludeTests ? [] : ["coverage*"],
|
|
113
|
+
"lib",
|
|
114
|
+
"node_modules",
|
|
115
|
+
"pnpm-lock.yaml"
|
|
116
|
+
],
|
|
117
|
+
words: [
|
|
118
|
+
"Codecov",
|
|
119
|
+
"codespace",
|
|
120
|
+
"commitlint",
|
|
121
|
+
"contributorsrc",
|
|
122
|
+
"conventionalcommits",
|
|
123
|
+
...options.excludeLintKnip ? [] : ["knip"],
|
|
124
|
+
"lcov",
|
|
125
|
+
"markdownlintignore",
|
|
126
|
+
"npmpackagejsonlintrc",
|
|
127
|
+
"outro",
|
|
128
|
+
"packagejson",
|
|
129
|
+
"tsup",
|
|
130
|
+
"quickstart",
|
|
131
|
+
"wontfix"
|
|
132
|
+
].sort()
|
|
133
|
+
})
|
|
134
|
+
},
|
|
135
|
+
...!options.excludeLintKnip && {
|
|
136
|
+
"knip.jsonc": await formatJson({
|
|
137
|
+
$schema: "https://unpkg.com/knip@latest/schema.json",
|
|
138
|
+
entry: ["src/index.ts!"],
|
|
139
|
+
ignoreExportsUsedInFile: {
|
|
140
|
+
interface: true,
|
|
141
|
+
type: true
|
|
142
|
+
},
|
|
143
|
+
project: ["src/**/*.ts!"]
|
|
144
|
+
})
|
|
145
|
+
},
|
|
146
|
+
"package.json": await writePackageJson(options),
|
|
147
|
+
"tsconfig.eslint.json": await formatJson({
|
|
148
|
+
extends: "./tsconfig.json",
|
|
149
|
+
include: ["."]
|
|
150
|
+
}),
|
|
151
|
+
"tsconfig.json": await formatJson({
|
|
152
|
+
compilerOptions: {
|
|
153
|
+
declaration: true,
|
|
154
|
+
declarationMap: true,
|
|
155
|
+
esModuleInterop: true,
|
|
156
|
+
module: "NodeNext",
|
|
157
|
+
moduleResolution: "NodeNext",
|
|
158
|
+
outDir: "lib",
|
|
159
|
+
resolveJsonModule: true,
|
|
160
|
+
skipLibCheck: true,
|
|
161
|
+
sourceMap: true,
|
|
162
|
+
strict: true,
|
|
163
|
+
target: "ES2022"
|
|
164
|
+
},
|
|
165
|
+
include: ["src"]
|
|
166
|
+
}),
|
|
167
|
+
"tsup.config.ts": await formatTypeScript(`import { defineConfig } from "tsup";
|
|
168
|
+
|
|
169
|
+
export default defineConfig({
|
|
170
|
+
bundle: false,
|
|
171
|
+
clean: true,
|
|
172
|
+
dts: true,
|
|
173
|
+
entry: ["src/**/*.ts"${options.excludeTests ? "" : `, "!src/**/*.test.*"`}],
|
|
174
|
+
format: "esm",
|
|
175
|
+
outDir: "lib",
|
|
176
|
+
sourcemap: true,
|
|
177
|
+
});
|
|
178
|
+
`),
|
|
179
|
+
...!options.excludeTests && {
|
|
180
|
+
"vitest.config.ts": `import { defineConfig } from "vitest/config";
|
|
181
|
+
|
|
182
|
+
export default defineConfig({
|
|
183
|
+
test: {
|
|
184
|
+
clearMocks: true,
|
|
185
|
+
coverage: {
|
|
186
|
+
all: true,
|
|
187
|
+
exclude: ["lib"],
|
|
188
|
+
include: ["src"],
|
|
189
|
+
reporter: ["html", "lcov"],
|
|
190
|
+
},
|
|
191
|
+
exclude: ["lib", "node_modules"],
|
|
192
|
+
setupFiles: ["console-fail-test/setup"],
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
`
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export {
|
|
200
|
+
createRootFiles
|
|
201
|
+
};
|
|
202
|
+
//# sourceMappingURL=rootFiles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/steps/writing/creation/rootFiles.ts"],"sourcesContent":["import { Options } from \"../../../shared/types.js\";\nimport { createESLintRC } from \"./createESLintRC.js\";\nimport { formatIgnoreFile } from \"./formatters/formatIgnoreFile.js\";\nimport { formatJson } from \"./formatters/formatJson.js\";\nimport { formatTypeScript } from \"./formatters/formatTypeScript.js\";\nimport { writeAllContributorsRC } from \"./writeAllContributorsRC.js\";\nimport { writePackageJson } from \"./writePackageJson.js\";\n\nexport async function createRootFiles(options: Options) {\n\treturn {\n\t\t\".all-contributorsrc\": await writeAllContributorsRC(options),\n\t\t\".eslintignore\": formatIgnoreFile(\n\t\t\t[\n\t\t\t\t\"!.*\",\n\t\t\t\t...(options.excludeTests ? [] : [\"coverage*\"]),\n\t\t\t\t\"lib\",\n\t\t\t\t\"node_modules\",\n\t\t\t\t\"pnpm-lock.yaml\",\n\t\t\t].filter(Boolean),\n\t\t),\n\t\t\".eslintrc.cjs\": await createESLintRC(options),\n\t\t\".gitignore\": formatIgnoreFile([\n\t\t\t...(options.excludeTests ? [] : [\"coverage*/\"]),\n\t\t\t\"lib/\",\n\t\t\t\"node_modules/\",\n\t\t]),\n\t\t...(!options.excludeLintMd && {\n\t\t\t\".markdownlint.json\": await formatJson({\n\t\t\t\textends: \"markdownlint/style/prettier\",\n\t\t\t\t\"first-line-h1\": false,\n\t\t\t\t\"no-inline-html\": false,\n\t\t\t}),\n\t\t\t\".markdownlintignore\": formatIgnoreFile([\n\t\t\t\t\".github/CODE_OF_CONDUCT.md\",\n\t\t\t\t\"CHANGELOG.md\",\n\t\t\t\t\"lib/\",\n\t\t\t\t\"node_modules/\",\n\t\t\t]),\n\t\t}),\n\t\t...(!options.excludeLintPackageJson && {\n\t\t\t\".npmpackagejsonlintrc.json\": await formatJson({\n\t\t\t\textends: \"npm-package-json-lint-config-default\",\n\t\t\t\trules: {\n\t\t\t\t\t\"require-description\": \"error\",\n\t\t\t\t\t\"require-license\": \"error\",\n\t\t\t\t},\n\t\t\t}),\n\t\t}),\n\t\t\".nvmrc\": `18.17.1\\n`,\n\t\t\".prettierignore\": formatIgnoreFile([\n\t\t\t...(options.excludeTests ? [] : [\"coverage*/\"]),\n\t\t\t\"lib/\",\n\t\t\t\"pnpm-lock.yaml\",\n\t\t\t\"\",\n\t\t\t\"# See https://github.com/all-contributors/cli/issues/347\",\n\t\t\t\".all-contributorsrc\",\n\t\t]),\n\t\t\".prettierrc\": await formatJson({\n\t\t\t$schema: \"http://json.schemastore.org/prettierrc\",\n\t\t\toverrides: [\n\t\t\t\t{\n\t\t\t\t\tfiles: \".*rc\",\n\t\t\t\t\toptions: { parser: \"json\" },\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tfiles: \".nvmrc\",\n\t\t\t\t\toptions: { parser: \"yaml\" },\n\t\t\t\t},\n\t\t\t],\n\t\t\tplugins: [\"prettier-plugin-curly\", \"prettier-plugin-packagejson\"],\n\t\t\tuseTabs: true,\n\t\t}),\n\t\t...(!options.excludeReleases && {\n\t\t\t\".release-it.json\": await formatJson({\n\t\t\t\tgit: {\n\t\t\t\t\tcommitMessage: \"chore: release v${version}\",\n\t\t\t\t\trequireCommits: true,\n\t\t\t\t},\n\t\t\t\tgithub: {\n\t\t\t\t\tautoGenerate: true,\n\t\t\t\t\trelease: true,\n\t\t\t\t\treleaseName: \"v${version}\",\n\t\t\t\t},\n\t\t\t}),\n\t\t}),\n\t\t\"LICENSE.md\": `# MIT License\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n`,\n\t\t...(!options.excludeLintSpelling && {\n\t\t\t\"cspell.json\": await formatJson({\n\t\t\t\tdictionaries: [\"typescript\"],\n\t\t\t\tignorePaths: [\n\t\t\t\t\t\".github\",\n\t\t\t\t\t\"CHANGELOG.md\",\n\t\t\t\t\t...(options.excludeTests ? [] : [\"coverage*\"]),\n\t\t\t\t\t\"lib\",\n\t\t\t\t\t\"node_modules\",\n\t\t\t\t\t\"pnpm-lock.yaml\",\n\t\t\t\t],\n\t\t\t\twords: [\n\t\t\t\t\t\"Codecov\",\n\t\t\t\t\t\"codespace\",\n\t\t\t\t\t\"commitlint\",\n\t\t\t\t\t\"contributorsrc\",\n\t\t\t\t\t\"conventionalcommits\",\n\t\t\t\t\t...(options.excludeLintKnip ? [] : [\"knip\"]),\n\t\t\t\t\t\"lcov\",\n\t\t\t\t\t\"markdownlintignore\",\n\t\t\t\t\t\"npmpackagejsonlintrc\",\n\t\t\t\t\t\"outro\",\n\t\t\t\t\t\"packagejson\",\n\t\t\t\t\t\"tsup\",\n\t\t\t\t\t\"quickstart\",\n\t\t\t\t\t\"wontfix\",\n\t\t\t\t].sort(),\n\t\t\t}),\n\t\t}),\n\t\t...(!options.excludeLintKnip && {\n\t\t\t\"knip.jsonc\": await formatJson({\n\t\t\t\t$schema: \"https://unpkg.com/knip@latest/schema.json\",\n\t\t\t\tentry: [\"src/index.ts!\"],\n\t\t\t\tignoreExportsUsedInFile: {\n\t\t\t\t\tinterface: true,\n\t\t\t\t\ttype: true,\n\t\t\t\t},\n\t\t\t\tproject: [\"src/**/*.ts!\"],\n\t\t\t}),\n\t\t}),\n\t\t\"package.json\": await writePackageJson(options),\n\t\t\"tsconfig.eslint.json\": await formatJson({\n\t\t\textends: \"./tsconfig.json\",\n\t\t\tinclude: [\".\"],\n\t\t}),\n\t\t\"tsconfig.json\": await formatJson({\n\t\t\tcompilerOptions: {\n\t\t\t\tdeclaration: true,\n\t\t\t\tdeclarationMap: true,\n\t\t\t\tesModuleInterop: true,\n\t\t\t\tmodule: \"NodeNext\",\n\t\t\t\tmoduleResolution: \"NodeNext\",\n\t\t\t\toutDir: \"lib\",\n\t\t\t\tresolveJsonModule: true,\n\t\t\t\tskipLibCheck: true,\n\t\t\t\tsourceMap: true,\n\t\t\t\tstrict: true,\n\t\t\t\ttarget: \"ES2022\",\n\t\t\t},\n\t\t\tinclude: [\"src\"],\n\t\t}),\n\t\t\"tsup.config.ts\":\n\t\t\tawait formatTypeScript(`import { defineConfig } from \"tsup\";\n\n\t\texport default defineConfig({\n\t\t\tbundle: false,\n\t\t\tclean: true,\n\t\t\tdts: true,\n\t\t\tentry: [\"src/**/*.ts\"${options.excludeTests ? \"\" : `, \"!src/**/*.test.*\"`}],\n\t\t\tformat: \"esm\",\n\t\t\toutDir: \"lib\",\n\t\t\tsourcemap: true,\n\t\t});\n\t\t`),\n\t\t...(!options.excludeTests && {\n\t\t\t\"vitest.config.ts\": `import { defineConfig } from \"vitest/config\";\n\nexport default defineConfig({\n\ttest: {\n\t\tclearMocks: true,\n\t\tcoverage: {\n\t\t\tall: true,\n\t\t\texclude: [\"lib\"],\n\t\t\tinclude: [\"src\"],\n\t\t\treporter: [\"html\", \"lcov\"],\n\t\t},\n\t\texclude: [\"lib\", \"node_modules\"],\n\t\tsetupFiles: [\"console-fail-test/setup\"],\n\t},\n});\n`,\n\t\t}),\n\t};\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { formatTypeScript } from "./formatters/formatTypeScript.js";
|
|
2
|
+
async function createSrc(options) {
|
|
3
|
+
return {
|
|
4
|
+
...!options.excludeTests && {
|
|
5
|
+
"greet.test.ts": await formatTypeScript(
|
|
6
|
+
`
|
|
7
|
+
import { describe, expect, it, vi } from "vitest";
|
|
8
|
+
|
|
9
|
+
import { greet } from "./greet.js";
|
|
10
|
+
|
|
11
|
+
const message = "Yay, testing!";
|
|
12
|
+
|
|
13
|
+
describe("greet", () => {
|
|
14
|
+
it("logs to the console once when message is provided as a string", () => {
|
|
15
|
+
const logger = vi.spyOn(console, "log").mockImplementation(() => undefined);
|
|
16
|
+
|
|
17
|
+
greet(message);
|
|
18
|
+
|
|
19
|
+
expect(logger).toHaveBeenCalledWith(message);
|
|
20
|
+
expect(logger).toHaveBeenCalledTimes(1);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("logs to the console once when message is provided as an object", () => {
|
|
24
|
+
const logger = vi.spyOn(console, "log").mockImplementation(() => undefined);
|
|
25
|
+
|
|
26
|
+
greet({ message });
|
|
27
|
+
|
|
28
|
+
expect(logger).toHaveBeenCalledWith(message);
|
|
29
|
+
expect(logger).toHaveBeenCalledTimes(1);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("logs once when times is not provided in an object", () => {
|
|
33
|
+
const logger = vi.fn();
|
|
34
|
+
|
|
35
|
+
greet({ logger, message });
|
|
36
|
+
|
|
37
|
+
expect(logger).toHaveBeenCalledWith(message);
|
|
38
|
+
expect(logger).toHaveBeenCalledTimes(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("logs a specified number of times when times is provided", () => {
|
|
42
|
+
const logger = vi.fn();
|
|
43
|
+
const times = 7;
|
|
44
|
+
|
|
45
|
+
greet({ logger, message, times });
|
|
46
|
+
|
|
47
|
+
expect(logger).toHaveBeenCalledWith(message);
|
|
48
|
+
expect(logger).toHaveBeenCalledTimes(7);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
`
|
|
52
|
+
)
|
|
53
|
+
},
|
|
54
|
+
"greet.ts": await formatTypeScript(
|
|
55
|
+
`import { GreetOptions } from "./types.js";
|
|
56
|
+
|
|
57
|
+
export function greet(options: GreetOptions | string) {
|
|
58
|
+
const {
|
|
59
|
+
logger = console.log.bind(console),
|
|
60
|
+
message,
|
|
61
|
+
times = 1,
|
|
62
|
+
} = typeof options === "string" ? { message: options } : options;
|
|
63
|
+
|
|
64
|
+
for (let i = 0; i < times; i += 1) {
|
|
65
|
+
logger(message);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
`
|
|
69
|
+
),
|
|
70
|
+
"index.ts": await formatTypeScript(
|
|
71
|
+
`
|
|
72
|
+
export * from "./greet.js";
|
|
73
|
+
export * from "./types.js";
|
|
74
|
+
`
|
|
75
|
+
),
|
|
76
|
+
"types.ts": await formatTypeScript(
|
|
77
|
+
`
|
|
78
|
+
export interface GreetOptions {
|
|
79
|
+
logger?: (message: string) => void;
|
|
80
|
+
message: string;
|
|
81
|
+
times?: number;
|
|
82
|
+
}
|
|
83
|
+
`
|
|
84
|
+
)
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export {
|
|
88
|
+
createSrc
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=src.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/steps/writing/creation/src.ts"],"sourcesContent":["import { Options } from \"../../../shared/types.js\";\nimport { formatTypeScript } from \"./formatters/formatTypeScript.js\";\n\nexport async function createSrc(options: Options) {\n\treturn {\n\t\t...(!options.excludeTests && {\n\t\t\t\"greet.test.ts\": await formatTypeScript(\n\t\t\t\t`\n\t\t\t\t\timport { describe, expect, it, vi } from \"vitest\";\n\n\t\t\t\t\timport { greet } from \"./greet.js\";\n\n\t\t\t\t\tconst message = \"Yay, testing!\";\n\n\t\t\t\t\tdescribe(\"greet\", () => {\n\t\t\t\t\t\tit(\"logs to the console once when message is provided as a string\", () => {\n\t\t\t\t\t\t\tconst logger = vi.spyOn(console, \"log\").mockImplementation(() => undefined);\n\n\t\t\t\t\t\t\tgreet(message);\n\n\t\t\t\t\t\t\texpect(logger).toHaveBeenCalledWith(message);\n\t\t\t\t\t\t\texpect(logger).toHaveBeenCalledTimes(1);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tit(\"logs to the console once when message is provided as an object\", () => {\n\t\t\t\t\t\t\tconst logger = vi.spyOn(console, \"log\").mockImplementation(() => undefined);\n\n\t\t\t\t\t\t\tgreet({ message });\n\n\t\t\t\t\t\t\texpect(logger).toHaveBeenCalledWith(message);\n\t\t\t\t\t\t\texpect(logger).toHaveBeenCalledTimes(1);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tit(\"logs once when times is not provided in an object\", () => {\n\t\t\t\t\t\t\tconst logger = vi.fn();\n\n\t\t\t\t\t\t\tgreet({ logger, message });\n\n\t\t\t\t\t\t\texpect(logger).toHaveBeenCalledWith(message);\n\t\t\t\t\t\t\texpect(logger).toHaveBeenCalledTimes(1);\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tit(\"logs a specified number of times when times is provided\", () => {\n\t\t\t\t\t\t\tconst logger = vi.fn();\n\t\t\t\t\t\t\tconst times = 7;\n\n\t\t\t\t\t\t\tgreet({ logger, message, times });\n\n\t\t\t\t\t\t\texpect(logger).toHaveBeenCalledWith(message);\n\t\t\t\t\t\t\texpect(logger).toHaveBeenCalledTimes(7);\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t`,\n\t\t\t),\n\t\t}),\n\t\t\"greet.ts\": await formatTypeScript(\n\t\t\t`import { GreetOptions } from \"./types.js\";\n\n\t\t\t\texport function greet(options: GreetOptions | string) {\n\t\t\t\t\tconst {\n\t\t\t\t\t\tlogger = console.log.bind(console),\n\t\t\t\t\t\tmessage,\n\t\t\t\t\t\ttimes = 1,\n\t\t\t\t\t} = typeof options === \"string\" ? { message: options } : options;\n\t\t\t\t\n\t\t\t\t\tfor (let i = 0; i < times; i += 1) {\n\t\t\t\t\t\tlogger(message);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t`,\n\t\t),\n\t\t\"index.ts\": await formatTypeScript(\n\t\t\t`\n\t\t\t\texport * from \"./greet.js\";\n\t\t\t\texport * from \"./types.js\";\n\t\t\t`,\n\t\t),\n\t\t\"types.ts\": await formatTypeScript(\n\t\t\t`\n\t\t\t\texport interface GreetOptions {\n\t\t\t\t\tlogger?: (message: string) => void;\n\t\t\t\t\tmessage: string;\n\t\t\t\t\ttimes?: number;\n\t\t\t\t}\n\t\t\t`,\n\t\t),\n\t};\n}\n"],"mappings":"AACA,SAAS,wBAAwB;AAEjC,eAAsB,UAAU,SAAkB;AACjD,SAAO;AAAA,IACN,GAAI,CAAC,QAAQ,gBAAgB;AAAA,MAC5B,iBAAiB,MAAM;AAAA,QACtB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MA8CD;AAAA,IACD;AAAA,IACA,YAAY,MAAM;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAcD;AAAA,IACA,YAAY,MAAM;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA,IAID;AAAA,IACA,YAAY,MAAM;AAAA,MACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAOD;AAAA,EACD;AACD;","names":[]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFileSafeAsJson } from "../../../shared/readFileSafeAsJson.js";
|
|
2
|
+
import { formatJson } from "./formatters/formatJson.js";
|
|
3
|
+
async function writeAllContributorsRC(options) {
|
|
4
|
+
const existing = await readFileSafeAsJson(
|
|
5
|
+
".all-contributorsrc"
|
|
6
|
+
);
|
|
7
|
+
return await formatJson({
|
|
8
|
+
badgeTemplate: '<img alt="All Contributors: <%= contributors.length %>" src="https://img.shields.io/badge/all_contributors-<%= contributors.length %>-21bb42.svg" />',
|
|
9
|
+
commit: false,
|
|
10
|
+
commitConvention: "angular",
|
|
11
|
+
contributors: existing?.contributors ?? [],
|
|
12
|
+
contributorsPerLine: 7,
|
|
13
|
+
contributorsSortAlphabetically: true,
|
|
14
|
+
files: ["README.md"],
|
|
15
|
+
imageSize: 100,
|
|
16
|
+
projectName: options.repository,
|
|
17
|
+
projectOwner: options.owner,
|
|
18
|
+
repoHost: "https://github.com",
|
|
19
|
+
repoType: "github"
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
writeAllContributorsRC
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=writeAllContributorsRC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/steps/writing/creation/writeAllContributorsRC.ts"],"sourcesContent":["import { readFileSafeAsJson } from \"../../../shared/readFileSafeAsJson.js\";\nimport { AllContributorsData, Options } from \"../../../shared/types.js\";\nimport { formatJson } from \"./formatters/formatJson.js\";\n\nexport async function writeAllContributorsRC(options: Options) {\n\tconst existing = (await readFileSafeAsJson(\n\t\t\".all-contributorsrc\",\n\t)) as AllContributorsData | null;\n\n\treturn await formatJson({\n\t\tbadgeTemplate:\n\t\t\t'<img alt=\"All Contributors: <%= contributors.length %>\" src=\"https://img.shields.io/badge/all_contributors-<%= contributors.length %>-21bb42.svg\" />',\n\t\tcommit: false,\n\t\tcommitConvention: \"angular\",\n\t\tcontributors: existing?.contributors ?? [],\n\t\tcontributorsPerLine: 7,\n\t\tcontributorsSortAlphabetically: true,\n\t\tfiles: [\"README.md\"],\n\t\timageSize: 100,\n\t\tprojectName: options.repository,\n\t\tprojectOwner: options.owner,\n\t\trepoHost: \"https://github.com\",\n\t\trepoType: \"github\",\n\t});\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAE3B,eAAsB,uBAAuB,SAAkB;AAC9D,QAAM,WAAY,MAAM;AAAA,IACvB;AAAA,EACD;AAEA,SAAO,MAAM,WAAW;AAAA,IACvB,eACC;AAAA,IACD,QAAQ;AAAA,IACR,kBAAkB;AAAA,IAClB,cAAc,UAAU,gBAAgB,CAAC;AAAA,IACzC,qBAAqB;AAAA,IACrB,gCAAgC;AAAA,IAChC,OAAO,CAAC,WAAW;AAAA,IACnB,WAAW;AAAA,IACX,aAAa,QAAQ;AAAA,IACrB,cAAc,QAAQ;AAAA,IACtB,UAAU;AAAA,IACV,UAAU;AAAA,EACX,CAAC;AACF;","names":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { readFileSafeAsJson } from "../../../shared/readFileSafeAsJson.js";
|
|
2
|
+
import { formatJson } from "./formatters/formatJson.js";
|
|
3
|
+
const devDependenciesToRemove = [
|
|
4
|
+
"@babel/core",
|
|
5
|
+
"@babel/preset-env",
|
|
6
|
+
"@babel/preset-react",
|
|
7
|
+
"@babel/preset-typescript",
|
|
8
|
+
"@swc/jest",
|
|
9
|
+
"ava",
|
|
10
|
+
"babel-jest",
|
|
11
|
+
"commitlint",
|
|
12
|
+
"cson-parser",
|
|
13
|
+
"esbuild",
|
|
14
|
+
"eslint-config-prettier",
|
|
15
|
+
"eslint-plugin-prettier",
|
|
16
|
+
"eslint-plugin-simple-import-sort",
|
|
17
|
+
"jasmine",
|
|
18
|
+
"jest",
|
|
19
|
+
"mocha",
|
|
20
|
+
"npm-run-all",
|
|
21
|
+
"pretty-quick"
|
|
22
|
+
];
|
|
23
|
+
async function writePackageJson(options) {
|
|
24
|
+
const existingPackageJson = await readFileSafeAsJson("./package.json") ?? {};
|
|
25
|
+
return await formatJson({
|
|
26
|
+
// If we didn't already have a version, set it to 0.0.0
|
|
27
|
+
version: "0.0.0",
|
|
28
|
+
// To start, copy over all existing package fields (e.g. "dependencies")
|
|
29
|
+
...existingPackageJson,
|
|
30
|
+
author: { email: options.email, name: options.author },
|
|
31
|
+
description: options.description,
|
|
32
|
+
// We copy all existing dev dependencies except those we know are not used anymore
|
|
33
|
+
devDependencies: copyDevDependencies(existingPackageJson),
|
|
34
|
+
// Remove fields we know we don't want, such as old or redundant configs
|
|
35
|
+
eslintConfig: void 0,
|
|
36
|
+
husky: void 0,
|
|
37
|
+
prettierConfig: void 0,
|
|
38
|
+
types: void 0,
|
|
39
|
+
// The rest of the fields are ones we know from our template
|
|
40
|
+
engines: {
|
|
41
|
+
node: ">=18"
|
|
42
|
+
},
|
|
43
|
+
files: ["lib/", "package.json", "LICENSE.md", "README.md"],
|
|
44
|
+
license: "MIT",
|
|
45
|
+
"lint-staged": {
|
|
46
|
+
"*": "prettier --ignore-unknown --write"
|
|
47
|
+
},
|
|
48
|
+
main: "./lib/index.js",
|
|
49
|
+
name: options.repository,
|
|
50
|
+
packageManager: "pnpm@8.5.0",
|
|
51
|
+
publishConfig: {
|
|
52
|
+
provenance: true
|
|
53
|
+
},
|
|
54
|
+
repository: {
|
|
55
|
+
type: "git",
|
|
56
|
+
url: `https://github.com/${options.owner}/${options.repository}`
|
|
57
|
+
},
|
|
58
|
+
scripts: {
|
|
59
|
+
build: "tsup",
|
|
60
|
+
format: 'prettier "**/*" --ignore-unknown',
|
|
61
|
+
"format:write": "pnpm format --write",
|
|
62
|
+
lint: "eslint . .*js --max-warnings 0 --report-unused-disable-directives",
|
|
63
|
+
...!options.excludeLintKnip && {
|
|
64
|
+
"lint:knip": "knip"
|
|
65
|
+
},
|
|
66
|
+
...!options.excludeLintMd && {
|
|
67
|
+
"lint:md": 'markdownlint "**/*.md" ".github/**/*.md" --rules sentences-per-line'
|
|
68
|
+
},
|
|
69
|
+
...!options.excludeLintPackageJson && {
|
|
70
|
+
"lint:package-json": "npmPkgJsonLint ."
|
|
71
|
+
},
|
|
72
|
+
...!options.excludeLintPackages && {
|
|
73
|
+
"lint:packages": "pnpm dedupe --check"
|
|
74
|
+
},
|
|
75
|
+
...!options.excludeLintSpelling && {
|
|
76
|
+
"lint:spelling": 'cspell "**" ".github/**/*"'
|
|
77
|
+
},
|
|
78
|
+
prepare: "husky install",
|
|
79
|
+
...!options.excludeReleases && {
|
|
80
|
+
"should-semantic-release": "should-semantic-release --verbose"
|
|
81
|
+
},
|
|
82
|
+
...!options.excludeReleases && { test: "vitest" },
|
|
83
|
+
tsc: "tsc"
|
|
84
|
+
},
|
|
85
|
+
type: "module"
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function copyDevDependencies(existingPackageJson) {
|
|
89
|
+
const devDependencies = "devDependencies" in existingPackageJson ? existingPackageJson.devDependencies : {};
|
|
90
|
+
for (const devDependencyToRemove of devDependenciesToRemove) {
|
|
91
|
+
delete devDependencies[devDependencyToRemove];
|
|
92
|
+
}
|
|
93
|
+
return devDependencies;
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
writePackageJson
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=writePackageJson.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/steps/writing/creation/writePackageJson.ts"],"sourcesContent":["import { readFileSafeAsJson } from \"../../../shared/readFileSafeAsJson.js\";\nimport { Options } from \"../../../shared/types.js\";\nimport { formatJson } from \"./formatters/formatJson.js\";\n\nconst devDependenciesToRemove = [\n\t\"@babel/core\",\n\t\"@babel/preset-env\",\n\t\"@babel/preset-react\",\n\t\"@babel/preset-typescript\",\n\t\"@swc/jest\",\n\t\"ava\",\n\t\"babel-jest\",\n\t\"commitlint\",\n\t\"cson-parser\",\n\t\"esbuild\",\n\t\"eslint-config-prettier\",\n\t\"eslint-plugin-prettier\",\n\t\"eslint-plugin-simple-import-sort\",\n\t\"jasmine\",\n\t\"jest\",\n\t\"mocha\",\n\t\"npm-run-all\",\n\t\"pretty-quick\",\n];\n\nexport async function writePackageJson(options: Options) {\n\tconst existingPackageJson =\n\t\t((await readFileSafeAsJson(\"./package.json\")) as null | object) ?? {};\n\n\treturn await formatJson({\n\t\t// If we didn't already have a version, set it to 0.0.0\n\t\tversion: \"0.0.0\",\n\n\t\t// To start, copy over all existing package fields (e.g. \"dependencies\")\n\t\t...existingPackageJson,\n\n\t\tauthor: { email: options.email, name: options.author },\n\t\tdescription: options.description,\n\n\t\t// We copy all existing dev dependencies except those we know are not used anymore\n\t\tdevDependencies: copyDevDependencies(existingPackageJson),\n\n\t\t// Remove fields we know we don't want, such as old or redundant configs\n\t\teslintConfig: undefined,\n\t\thusky: undefined,\n\t\tprettierConfig: undefined,\n\t\ttypes: undefined,\n\n\t\t// The rest of the fields are ones we know from our template\n\t\tengines: {\n\t\t\tnode: \">=18\",\n\t\t},\n\t\tfiles: [\"lib/\", \"package.json\", \"LICENSE.md\", \"README.md\"],\n\t\tlicense: \"MIT\",\n\t\t\"lint-staged\": {\n\t\t\t\"*\": \"prettier --ignore-unknown --write\",\n\t\t},\n\t\tmain: \"./lib/index.js\",\n\t\tname: options.repository,\n\t\tpackageManager: \"pnpm@8.5.0\",\n\t\tpublishConfig: {\n\t\t\tprovenance: true,\n\t\t},\n\t\trepository: {\n\t\t\ttype: \"git\",\n\t\t\turl: `https://github.com/${options.owner}/${options.repository}`,\n\t\t},\n\t\tscripts: {\n\t\t\tbuild: \"tsup\",\n\t\t\tformat: 'prettier \"**/*\" --ignore-unknown',\n\t\t\t\"format:write\": \"pnpm format --write\",\n\t\t\tlint: \"eslint . .*js --max-warnings 0 --report-unused-disable-directives\",\n\t\t\t...(!options.excludeLintKnip && {\n\t\t\t\t\"lint:knip\": \"knip\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintMd && {\n\t\t\t\t\"lint:md\":\n\t\t\t\t\t'markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line',\n\t\t\t}),\n\t\t\t...(!options.excludeLintPackageJson && {\n\t\t\t\t\"lint:package-json\": \"npmPkgJsonLint .\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintPackages && {\n\t\t\t\t\"lint:packages\": \"pnpm dedupe --check\",\n\t\t\t}),\n\t\t\t...(!options.excludeLintSpelling && {\n\t\t\t\t\"lint:spelling\": 'cspell \"**\" \".github/**/*\"',\n\t\t\t}),\n\t\t\tprepare: \"husky install\",\n\t\t\t...(!options.excludeReleases && {\n\t\t\t\t\"should-semantic-release\": \"should-semantic-release --verbose\",\n\t\t\t}),\n\t\t\t...(!options.excludeReleases && { test: \"vitest\" }),\n\t\t\ttsc: \"tsc\",\n\t\t},\n\t\ttype: \"module\",\n\t});\n}\n\nfunction copyDevDependencies(existingPackageJson: object) {\n\tconst devDependencies =\n\t\t\"devDependencies\" in existingPackageJson\n\t\t\t? (existingPackageJson.devDependencies as Record<string, string>)\n\t\t\t: {};\n\n\tfor (const devDependencyToRemove of devDependenciesToRemove) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-dynamic-delete\n\t\tdelete devDependencies[devDependencyToRemove];\n\t}\n\n\treturn devDependencies;\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AAEnC,SAAS,kBAAkB;AAE3B,MAAM,0BAA0B;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAEA,eAAsB,iBAAiB,SAAkB;AACxD,QAAM,sBACH,MAAM,mBAAmB,gBAAgB,KAAwB,CAAC;AAErE,SAAO,MAAM,WAAW;AAAA;AAAA,IAEvB,SAAS;AAAA;AAAA,IAGT,GAAG;AAAA,IAEH,QAAQ,EAAE,OAAO,QAAQ,OAAO,MAAM,QAAQ,OAAO;AAAA,IACrD,aAAa,QAAQ;AAAA;AAAA,IAGrB,iBAAiB,oBAAoB,mBAAmB;AAAA;AAAA,IAGxD,cAAc;AAAA,IACd,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,OAAO;AAAA;AAAA,IAGP,SAAS;AAAA,MACR,MAAM;AAAA,IACP;AAAA,IACA,OAAO,CAAC,QAAQ,gBAAgB,cAAc,WAAW;AAAA,IACzD,SAAS;AAAA,IACT,eAAe;AAAA,MACd,KAAK;AAAA,IACN;AAAA,IACA,MAAM;AAAA,IACN,MAAM,QAAQ;AAAA,IACd,gBAAgB;AAAA,IAChB,eAAe;AAAA,MACd,YAAY;AAAA,IACb;AAAA,IACA,YAAY;AAAA,MACX,MAAM;AAAA,MACN,KAAK,sBAAsB,QAAQ,KAAK,IAAI,QAAQ,UAAU;AAAA,IAC/D;AAAA,IACA,SAAS;AAAA,MACR,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,gBAAgB;AAAA,MAChB,MAAM;AAAA,MACN,GAAI,CAAC,QAAQ,mBAAmB;AAAA,QAC/B,aAAa;AAAA,MACd;AAAA,MACA,GAAI,CAAC,QAAQ,iBAAiB;AAAA,QAC7B,WACC;AAAA,MACF;AAAA,MACA,GAAI,CAAC,QAAQ,0BAA0B;AAAA,QACtC,qBAAqB;AAAA,MACtB;AAAA,MACA,GAAI,CAAC,QAAQ,uBAAuB;AAAA,QACnC,iBAAiB;AAAA,MAClB;AAAA,MACA,GAAI,CAAC,QAAQ,uBAAuB;AAAA,QACnC,iBAAiB;AAAA,MAClB;AAAA,MACA,SAAS;AAAA,MACT,GAAI,CAAC,QAAQ,mBAAmB;AAAA,QAC/B,2BAA2B;AAAA,MAC5B;AAAA,MACA,GAAI,CAAC,QAAQ,mBAAmB,EAAE,MAAM,SAAS;AAAA,MACjD,KAAK;AAAA,IACN;AAAA,IACA,MAAM;AAAA,EACP,CAAC;AACF;AAEA,SAAS,oBAAoB,qBAA6B;AACzD,QAAM,kBACL,qBAAqB,sBACjB,oBAAoB,kBACrB,CAAC;AAEL,aAAW,yBAAyB,yBAAyB;AAE5D,WAAO,gBAAgB,qBAAqB;AAAA,EAC7C;AAEA,SAAO;AACR;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { $ } from "execa";
|
|
2
|
+
import { createStructure } from "./creation/index.js";
|
|
3
|
+
import { writeStructureWorker } from "./writeStructureWorker.js";
|
|
4
|
+
async function writeStructure(options) {
|
|
5
|
+
await writeStructureWorker(await createStructure(options), ".");
|
|
6
|
+
await $`chmod ug+x .husky/pre-commit`;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
writeStructure
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=writeStructure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/steps/writing/writeStructure.ts"],"sourcesContent":["import { $ } from \"execa\";\n\nimport { Options } from \"../../shared/types.js\";\nimport { createStructure } from \"./creation/index.js\";\nimport { writeStructureWorker } from \"./writeStructureWorker.js\";\n\nexport async function writeStructure(options: Options) {\n\tawait writeStructureWorker(await createStructure(options), \".\");\n\n\t// https://github.com/JoshuaKGoldberg/create-typescript-app/issues/718\n\tawait $`chmod ug+x .husky/pre-commit`;\n}\n"],"mappings":"AAAA,SAAS,SAAS;AAGlB,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AAErC,eAAsB,eAAe,SAAkB;AACtD,QAAM,qBAAqB,MAAM,gBAAgB,OAAO,GAAG,GAAG;AAG9D,QAAM;AACP;","names":[]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as fs from "node:fs/promises";
|
|
2
|
+
import * as path from "path";
|
|
3
|
+
import prettier from "prettier";
|
|
4
|
+
async function writeStructureWorker(structure, basePath) {
|
|
5
|
+
await fs.mkdir(basePath, { recursive: true });
|
|
6
|
+
for (const [fileName, contents] of Object.entries(structure)) {
|
|
7
|
+
if (typeof contents === "string") {
|
|
8
|
+
await fs.writeFile(
|
|
9
|
+
path.join(basePath, fileName),
|
|
10
|
+
await format(fileName, contents)
|
|
11
|
+
);
|
|
12
|
+
} else {
|
|
13
|
+
await writeStructureWorker(contents, path.join(basePath, fileName));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
async function format(fileName, text) {
|
|
18
|
+
const parser = inferParser(fileName, text);
|
|
19
|
+
if (!parser) {
|
|
20
|
+
return text;
|
|
21
|
+
}
|
|
22
|
+
return await prettier.format(text, {
|
|
23
|
+
parser,
|
|
24
|
+
useTabs: true
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function inferParser(fileName, text) {
|
|
28
|
+
if (text.startsWith("{")) {
|
|
29
|
+
return "json";
|
|
30
|
+
}
|
|
31
|
+
switch (fileName.split(".").at(-1)) {
|
|
32
|
+
case "cjs":
|
|
33
|
+
case "js":
|
|
34
|
+
return "babel";
|
|
35
|
+
case "json":
|
|
36
|
+
return "json";
|
|
37
|
+
case "md":
|
|
38
|
+
return "markdown";
|
|
39
|
+
case "yml":
|
|
40
|
+
return "yaml";
|
|
41
|
+
}
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
writeStructureWorker
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=writeStructureWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/steps/writing/writeStructureWorker.ts"],"sourcesContent":["import * as fs from \"node:fs/promises\";\nimport * as path from \"path\";\nimport prettier from \"prettier\";\n\nimport { Structure } from \"./types.js\";\n\nexport async function writeStructureWorker(\n\tstructure: Structure,\n\tbasePath: string,\n) {\n\tawait fs.mkdir(basePath, { recursive: true });\n\n\tfor (const [fileName, contents] of Object.entries(structure)) {\n\t\tif (typeof contents === \"string\") {\n\t\t\tawait fs.writeFile(\n\t\t\t\tpath.join(basePath, fileName),\n\t\t\t\tawait format(fileName, contents),\n\t\t\t);\n\t\t} else {\n\t\t\tawait writeStructureWorker(contents, path.join(basePath, fileName));\n\t\t}\n\t}\n}\n\nasync function format(fileName: string, text: string) {\n\tconst parser = inferParser(fileName, text);\n\tif (!parser) {\n\t\treturn text;\n\t}\n\n\treturn await prettier.format(text, {\n\t\tparser,\n\t\tuseTabs: true,\n\t});\n}\n\nfunction inferParser(fileName: string, text: string) {\n\tif (text.startsWith(\"{\")) {\n\t\treturn \"json\";\n\t}\n\n\tswitch (fileName.split(\".\").at(-1)) {\n\t\tcase \"cjs\":\n\t\tcase \"js\":\n\t\t\treturn \"babel\";\n\t\tcase \"json\":\n\t\t\treturn \"json\";\n\t\tcase \"md\":\n\t\t\treturn \"markdown\";\n\t\tcase \"yml\":\n\t\t\treturn \"yaml\";\n\t}\n\n\treturn undefined;\n}\n"],"mappings":"AAAA,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,OAAO,cAAc;AAIrB,eAAsB,qBACrB,WACA,UACC;AACD,QAAM,GAAG,MAAM,UAAU,EAAE,WAAW,KAAK,CAAC;AAE5C,aAAW,CAAC,UAAU,QAAQ,KAAK,OAAO,QAAQ,SAAS,GAAG;AAC7D,QAAI,OAAO,aAAa,UAAU;AACjC,YAAM,GAAG;AAAA,QACR,KAAK,KAAK,UAAU,QAAQ;AAAA,QAC5B,MAAM,OAAO,UAAU,QAAQ;AAAA,MAChC;AAAA,IACD,OAAO;AACN,YAAM,qBAAqB,UAAU,KAAK,KAAK,UAAU,QAAQ,CAAC;AAAA,IACnE;AAAA,EACD;AACD;AAEA,eAAe,OAAO,UAAkB,MAAc;AACrD,QAAM,SAAS,YAAY,UAAU,IAAI;AACzC,MAAI,CAAC,QAAQ;AACZ,WAAO;AAAA,EACR;AAEA,SAAO,MAAM,SAAS,OAAO,MAAM;AAAA,IAClC;AAAA,IACA,SAAS;AAAA,EACV,CAAC;AACF;AAEA,SAAS,YAAY,UAAkB,MAAc;AACpD,MAAI,KAAK,WAAW,GAAG,GAAG;AACzB,WAAO;AAAA,EACR;AAEA,UAAQ,SAAS,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG;AAAA,IACnC,KAAK;AAAA,IACL,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,IACR,KAAK;AACJ,aAAO;AAAA,EACT;AAEA,SAAO;AACR;","names":[]}
|
package/lib/types.d.ts
ADDED
package/lib/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=types.js.map
|
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|