@jakubmazanec/carson-templates 1.0.0 → 2.0.0-next.2fa8a2c
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 +0 -2
- package/README.md +1 -1
- package/build/constants.d.ts +60 -0
- package/build/constants.js +89 -0
- package/build/constants.js.map +7 -0
- package/build/dependency-versions.d.ts +1 -0
- package/build/dependency-versions.js +58 -0
- package/build/dependency-versions.js.map +7 -0
- package/build/getDependencies.d.ts +2 -0
- package/build/getDependencies.js +44 -0
- package/build/getDependencies.js.map +7 -0
- package/build/getDevelopmentBranch.d.ts +2 -0
- package/build/getDevelopmentBranch.js +11 -0
- package/build/getDevelopmentBranch.js.map +7 -0
- package/build/getMainBranch.d.ts +2 -0
- package/build/getMainBranch.js +11 -0
- package/build/getMainBranch.js.map +7 -0
- package/build/getReferences.d.ts +4 -0
- package/build/getReferences.js +20 -0
- package/build/getReferences.js.map +7 -0
- package/build/getWorkspaceName.d.ts +2 -0
- package/build/getWorkspaceName.js +16 -0
- package/build/getWorkspaceName.js.map +7 -0
- package/build/main.d.ts +8 -0
- package/build/main.js +10 -0
- package/build/main.js.map +7 -0
- package/package.json +31 -20
- package/source/constants.ts +94 -0
- package/source/dependency-versions.ts +69 -0
- package/source/getDependencies.ts +58 -0
- package/source/getDevelopmentBranch.ts +13 -0
- package/source/getMainBranch.ts +13 -0
- package/source/getReferences.ts +29 -0
- package/source/getWorkspaceName.ts +20 -0
- package/source/main.ts +8 -0
- package/templates/projects/carson-templates/.eslintrc.cjs.ejs +21 -0
- package/templates/projects/carson-templates/.prettierignore.ejs +3 -0
- package/templates/projects/carson-templates/CONTRIBUTING.md.ejs +3 -0
- package/templates/projects/carson-templates/package.json.ejs +26 -12
- package/templates/projects/carson-templates/prettier.config.cjs.ejs +3 -0
- package/templates/projects/carson-templates/source/main.ts.check.ejs +4 -0
- package/templates/projects/carson-templates/source/main.ts.create.ejs +6 -0
- package/templates/projects/carson-templates/tests/tsconfig.json.ejs +19 -12
- package/templates/projects/carson-templates/tsconfig.json.ejs +23 -9
- package/templates/projects/carson-templates/tsconfig.typecheck.json.ejs +1 -12
- package/templates/projects/carson-templates/typedoc.config.cjs.ejs +1 -10
- package/templates/projects/changesets-changelog/.eslintrc.cjs.ejs +21 -0
- package/templates/projects/changesets-changelog/.prettierignore.ejs +3 -0
- package/templates/projects/changesets-changelog/CONTRIBUTING.md.ejs +3 -0
- package/templates/projects/changesets-changelog/package.json.ejs +38 -20
- package/templates/projects/changesets-changelog/prettier.config.cjs.ejs +3 -0
- package/templates/projects/changesets-changelog/source/main.ts.check.ejs +4 -0
- package/templates/projects/changesets-changelog/source/main.ts.create.ejs +6 -0
- package/templates/projects/changesets-changelog/tests/tsconfig.json.ejs +19 -12
- package/templates/projects/changesets-changelog/tsconfig.json.ejs +23 -9
- package/templates/projects/changesets-changelog/tsconfig.typecheck.json.ejs +21 -10
- package/templates/projects/eslint-config/.eslintrc.cjs.ejs +21 -0
- package/templates/projects/eslint-config/.prettierignore.ejs +3 -0
- package/templates/projects/eslint-config/CONTRIBUTING.md.ejs +3 -0
- package/templates/projects/eslint-config/package.json.ejs +39 -25
- package/templates/projects/eslint-config/prettier.config.cjs.ejs +3 -0
- package/templates/projects/eslint-config/source/main.ts.check.ejs +4 -0
- package/templates/projects/eslint-config/source/main.ts.create.ejs +6 -0
- package/templates/projects/eslint-config/tsconfig.json.ejs +23 -9
- package/templates/projects/eslint-config/tsconfig.typecheck.json.ejs +20 -9
- package/templates/projects/library/.eslintrc.cjs.ejs +21 -0
- package/templates/projects/library/.prettierignore.ejs +3 -0
- package/templates/projects/library/CONTRIBUTING.md.ejs +18 -0
- package/templates/projects/library/README.md.create.ejs +36 -0
- package/templates/projects/library/package.json.create.ejs +1 -1
- package/templates/projects/library/package.json.ejs +35 -13
- package/templates/projects/library/prettier.config.cjs.ejs +3 -0
- package/templates/projects/library/source/main.ts.check.ejs +4 -0
- package/templates/projects/library/source/main.ts.create.ejs +5 -0
- package/templates/projects/library/tests/tsconfig.json.ejs +19 -12
- package/templates/projects/library/tsconfig.json.ejs +23 -9
- package/templates/projects/library/tsconfig.typecheck.json.ejs +20 -9
- package/templates/projects/library/typedoc.config.cjs.ejs +13 -7
- package/templates/projects/remix-app/.eslintrc.cjs.ejs +21 -0
- package/templates/projects/remix-app/.prettierignore.ejs +3 -0
- package/templates/projects/remix-app/CONTRIBUTING.md.ejs +3 -0
- package/templates/projects/remix-app/Dockerfile.ejs +47 -0
- package/templates/projects/remix-app/README.md.create.ejs +26 -0
- package/templates/projects/remix-app/app/entry.client.tsx.create.ejs +16 -0
- package/templates/projects/remix-app/app/root.tsx.create.ejs +26 -0
- package/templates/projects/remix-app/app/routes/_index.tsx.create.ejs +18 -0
- package/templates/projects/remix-app/app/tailwind.css.create.ejs +7 -0
- package/templates/projects/remix-app/config.json +4 -0
- package/templates/projects/remix-app/env.d.ts.ejs +14 -0
- package/templates/projects/remix-app/fly.toml.ejs +18 -0
- package/templates/projects/remix-app/package.json.create.ejs +14 -0
- package/templates/projects/remix-app/package.json.ejs +67 -0
- package/templates/projects/remix-app/postcss.config.cjs.ejs +18 -0
- package/templates/projects/remix-app/prettier.config.cjs.ejs +19 -0
- package/templates/projects/remix-app/tailwind.config.ts.ejs +21 -0
- package/templates/projects/remix-app/tests/setup.ts.ejs +13 -0
- package/templates/projects/remix-app/tests/tsconfig.json.ejs +24 -0
- package/templates/projects/remix-app/tsconfig.json.ejs +30 -0
- package/templates/projects/remix-app/tsconfig.typecheck.json.ejs +19 -0
- package/templates/projects/remix-app/vite.config.ts.ejs +40 -0
- package/templates/workspace/.eslintrc.cjs.ejs +9 -13
- package/templates/workspace/.github/workflows/{pull-request.yaml.ejs → check-pull-request.yaml.ejs} +30 -7
- package/templates/workspace/.github/workflows/merge-to-main-branch.yaml.ejs +12 -4
- package/templates/workspace/.github/workflows/release-pull-request.yaml.ejs +105 -0
- package/templates/workspace/.github/workflows/release.yaml.ejs +65 -105
- package/templates/workspace/.github/workflows/update-pull-request.yaml.ejs +139 -0
- package/templates/workspace/.gitignore.ejs +9 -1
- package/templates/workspace/.prettierignore.ejs +9 -10
- package/templates/workspace/CONTRIBUTING.md.ejs +18 -0
- package/templates/workspace/README.md.create.ejs +16 -0
- package/templates/workspace/README.md.insert.ejs +1 -0
- package/templates/workspace/package.json.ejs +6 -16
- package/templates/workspace/prettier.config.cjs.ejs +19 -0
- package/templates/workspace/tsconfig.json.ejs +23 -0
- package/templates/workspace/tsconfig.typecheck.json.ejs +10 -4
- package/templates/workspace/turbo.json.ejs +1 -1
- package/dist/main.d.ts +0 -10
- package/dist/main.js +0 -128
- package/dist/main.js.map +0 -1
- package/src/main.ts +0 -166
- package/templates/projects/carson-templates/.swcrc.ejs +0 -23
- package/templates/projects/carson-templates/jest.config.ts.ejs +0 -30
- package/templates/projects/carson-templates/src/main.ts.check.ejs +0 -5
- package/templates/projects/carson-templates/src/main.ts.create.ejs +0 -4
- package/templates/projects/changesets-changelog/.swcrc.ejs +0 -25
- package/templates/projects/changesets-changelog/jest.config.ts.ejs +0 -24
- package/templates/projects/changesets-changelog/src/main.ts.check.ejs +0 -5
- package/templates/projects/changesets-changelog/src/main.ts.create.ejs +0 -4
- package/templates/projects/eslint-config/.swcrc.ejs +0 -25
- package/templates/projects/eslint-config/jest.config.ts.ejs +0 -24
- package/templates/projects/eslint-config/src/main.ts.check.ejs +0 -5
- package/templates/projects/eslint-config/src/main.ts.create.ejs +0 -4
- package/templates/projects/eslint-config/tests/tsconfig.json.ejs +0 -17
- package/templates/projects/library/.swcrc.ejs +0 -23
- package/templates/projects/library/jest.config.ts.ejs +0 -30
- package/templates/projects/library/src/main.ts.check.ejs +0 -5
- package/templates/projects/library/src/main.ts.create.ejs +0 -4
- package/templates/workspace/prettier.config.js.ejs +0 -19
- package/templates/workspace/tsconfig.options.json.ejs +0 -24
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
export const BUILD_DIRECTORY = 'build';
|
|
2
|
+
export const SOURCE_DIRECTORY = 'source';
|
|
3
|
+
|
|
4
|
+
export const BUILD_TO_ESM_COMMAND = `esbuild "${SOURCE_DIRECTORY}/**/*" --platform=node --target=node20.8 --outdir=${BUILD_DIRECTORY} --sourcemap`;
|
|
5
|
+
export const BUILD_TO_CJS_COMMAND = `esbuild "${SOURCE_DIRECTORY}/**/*" --platform=node --target=node20.8 --format=cjs --outdir=${BUILD_DIRECTORY} --sourcemap`;
|
|
6
|
+
export const FORMAT_COMMAND = 'prettier . --write --ignore-unknown';
|
|
7
|
+
export const TEST_COMMAND = 'vitest run --coverage --passWithNoTests';
|
|
8
|
+
|
|
9
|
+
export const CARSON_PACKAGE_NAME = '@jakubmazanec/carson';
|
|
10
|
+
export const TEMPLATE_PACKAGE_NAME = '@jakubmazanec/carson-templates';
|
|
11
|
+
|
|
12
|
+
export const MAIN_BRANCH_NAMES = new Set(['main', 'master']);
|
|
13
|
+
export const DEVELOPMENT_BRANCH_NAMES = new Set(['development', 'develop', 'dev']);
|
|
14
|
+
|
|
15
|
+
export const LINT_IGNORE_PATTERNS = [
|
|
16
|
+
'.cache/',
|
|
17
|
+
'.turbo/',
|
|
18
|
+
'bin/',
|
|
19
|
+
'coverage/',
|
|
20
|
+
'node_modules/',
|
|
21
|
+
'public/',
|
|
22
|
+
'*.d.ts',
|
|
23
|
+
'*.json',
|
|
24
|
+
'*.md',
|
|
25
|
+
'*.mdx',
|
|
26
|
+
`${BUILD_DIRECTORY}/`,
|
|
27
|
+
].sort();
|
|
28
|
+
|
|
29
|
+
export const FORMAT_IGNORE_PATTERNS = [
|
|
30
|
+
'.cache/',
|
|
31
|
+
'.turbo/',
|
|
32
|
+
'coverage/',
|
|
33
|
+
'node_modules/',
|
|
34
|
+
'public/',
|
|
35
|
+
'npm-shrinkwrap.json',
|
|
36
|
+
'package-lock.json',
|
|
37
|
+
'CHANGELOG.md',
|
|
38
|
+
'LICENSE.md',
|
|
39
|
+
`${BUILD_DIRECTORY}/`,
|
|
40
|
+
].sort();
|
|
41
|
+
|
|
42
|
+
export const TSCONFIG_COMPILER_OPTIONS = {
|
|
43
|
+
allowSyntheticDefaultImports: true,
|
|
44
|
+
composite: true,
|
|
45
|
+
exactOptionalPropertyTypes: true,
|
|
46
|
+
forceConsistentCasingInFileNames: true,
|
|
47
|
+
isolatedModules: true,
|
|
48
|
+
jsx: 'react-jsx',
|
|
49
|
+
lib: ['dom', 'dom.iterable', 'es2022'],
|
|
50
|
+
module: 'node16',
|
|
51
|
+
moduleResolution: 'node16',
|
|
52
|
+
noEmitOnError: false, // TODO: change to `true` when this is fixed: https://github.com/kulshekhar/ts-jest/issues/4198
|
|
53
|
+
noImplicitOverride: true,
|
|
54
|
+
noImplicitReturns: true,
|
|
55
|
+
noUncheckedIndexedAccess: true,
|
|
56
|
+
skipLibCheck: true,
|
|
57
|
+
strict: true,
|
|
58
|
+
target: 'es2022',
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const PRETTIER_OPTIONS = {
|
|
62
|
+
arrowParens: 'always',
|
|
63
|
+
bracketSameLine: false,
|
|
64
|
+
bracketSpacing: false,
|
|
65
|
+
embeddedLanguageFormatting: 'auto',
|
|
66
|
+
experimentalTernaries: true,
|
|
67
|
+
htmlWhitespaceSensitivity: 'css',
|
|
68
|
+
jsxSingleQuote: false,
|
|
69
|
+
printWidth: 100,
|
|
70
|
+
proseWrap: 'always',
|
|
71
|
+
quoteProps: 'as-needed',
|
|
72
|
+
requirePragma: false,
|
|
73
|
+
semi: true,
|
|
74
|
+
singleQuote: true,
|
|
75
|
+
trailingComma: 'all',
|
|
76
|
+
// TODO: remove when this is fixed: https://github.com/prettier/prettier/issues/15956
|
|
77
|
+
overrides: [
|
|
78
|
+
{
|
|
79
|
+
files: ['tsconfig.json'],
|
|
80
|
+
options: {
|
|
81
|
+
trailingComma: 'none',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
export const TYPEDOC_CONFIG = {
|
|
88
|
+
plugin: 'typedoc-plugin-markdown',
|
|
89
|
+
entryPoints: [`./${SOURCE_DIRECTORY}/main.ts`],
|
|
90
|
+
out: 'docs',
|
|
91
|
+
readme: 'none',
|
|
92
|
+
githubPages: false,
|
|
93
|
+
hideBreadcrumbs: true,
|
|
94
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import {createRequire} from 'node:module';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
|
|
5
|
+
import {CARSON_PACKAGE_NAME, TEMPLATE_PACKAGE_NAME} from './constants.js';
|
|
6
|
+
|
|
7
|
+
let require = createRequire(import.meta.url);
|
|
8
|
+
let carsonPackageVersion =
|
|
9
|
+
semver
|
|
10
|
+
.minVersion(
|
|
11
|
+
(
|
|
12
|
+
JSON.parse(
|
|
13
|
+
fs.readFileSync(require.resolve(`${TEMPLATE_PACKAGE_NAME}/package.json`), {
|
|
14
|
+
encoding: 'utf8',
|
|
15
|
+
}),
|
|
16
|
+
) as {peerDependencies: Record<string, string>}
|
|
17
|
+
).peerDependencies[CARSON_PACKAGE_NAME] ?? '^1.0.0',
|
|
18
|
+
)
|
|
19
|
+
?.format() ?? '1.0.0';
|
|
20
|
+
let isCarsonPackageVersionPrerelease = !!semver.prerelease(carsonPackageVersion)?.length;
|
|
21
|
+
let templatesPackageVersion = (
|
|
22
|
+
JSON.parse(
|
|
23
|
+
fs.readFileSync(require.resolve(`${TEMPLATE_PACKAGE_NAME}/package.json`), {
|
|
24
|
+
encoding: 'utf8',
|
|
25
|
+
}),
|
|
26
|
+
) as {version: string}
|
|
27
|
+
).version;
|
|
28
|
+
let isTemplatesPackageVersionPrerelease = !!semver.prerelease(templatesPackageVersion)?.length;
|
|
29
|
+
|
|
30
|
+
export const DEPENDENCY_VERSIONS: Record<string, string> = {
|
|
31
|
+
[CARSON_PACKAGE_NAME]:
|
|
32
|
+
isCarsonPackageVersionPrerelease ? carsonPackageVersion : `^${carsonPackageVersion}`,
|
|
33
|
+
[TEMPLATE_PACKAGE_NAME]:
|
|
34
|
+
isTemplatesPackageVersionPrerelease ? templatesPackageVersion : `^${templatesPackageVersion}`,
|
|
35
|
+
|
|
36
|
+
'@changesets/cli': '^2.0.0',
|
|
37
|
+
'@remix-run/dev': '^2.0.0',
|
|
38
|
+
'@remix-run/express': '^2.0.0',
|
|
39
|
+
'@remix-run/node': '^2.0.0',
|
|
40
|
+
'@remix-run/react': '^2.0.0',
|
|
41
|
+
'@remix-run/serve': '^2.0.0',
|
|
42
|
+
'@testing-library/jest-dom': '^5.0.0',
|
|
43
|
+
'@types/lodash': '^4.0.0',
|
|
44
|
+
'@types/node': '^20.0.0',
|
|
45
|
+
'@types/react': '^18.0.0',
|
|
46
|
+
'@types/react-dom': '^18.0.0',
|
|
47
|
+
'@vitest/coverage-v8': '^1.0.0',
|
|
48
|
+
autoprefixer: '^10.0.0',
|
|
49
|
+
concurrently: '^8.0.0',
|
|
50
|
+
'cross-env': '^7.0.0',
|
|
51
|
+
'del-cli': '^5.0.0',
|
|
52
|
+
esbuild: '^0.19.0',
|
|
53
|
+
eslint: '^8.0.0',
|
|
54
|
+
lodash: '^4.0.0',
|
|
55
|
+
isbot: '^4.0.0',
|
|
56
|
+
'patch-package': '^6.0.0',
|
|
57
|
+
prettier: '^3.0.0',
|
|
58
|
+
'prettier-plugin-packagejson': '^2.0.0',
|
|
59
|
+
'prettier-plugin-tailwindcss': '^0.5.0',
|
|
60
|
+
react: '^18.0.0',
|
|
61
|
+
'react-dom': '^18.0.0',
|
|
62
|
+
tailwindcss: '^3.0.0',
|
|
63
|
+
turbo: '^1.0.0',
|
|
64
|
+
typedoc: '^0.24.0',
|
|
65
|
+
'typedoc-plugin-markdown': '^3.0.0',
|
|
66
|
+
typescript: '^5.0.0',
|
|
67
|
+
vite: '^5.0.0',
|
|
68
|
+
vitest: '^1.0.0',
|
|
69
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {type Workspace} from '@jakubmazanec/carson';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
|
|
4
|
+
import {TEMPLATE_PACKAGE_NAME} from './constants.js';
|
|
5
|
+
import {DEPENDENCY_VERSIONS} from './dependency-versions.js';
|
|
6
|
+
|
|
7
|
+
function getMajorVersion(version: string) {
|
|
8
|
+
return Number(version.split('.')[0]!.replace(/\D/, ''));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getDependencies(dependencies: string[], workspace: Workspace | Workspace<false>) {
|
|
12
|
+
const result: Record<string, string> = {};
|
|
13
|
+
|
|
14
|
+
for (const dependency of dependencies) {
|
|
15
|
+
const version = DEPENDENCY_VERSIONS[dependency];
|
|
16
|
+
|
|
17
|
+
if (version) {
|
|
18
|
+
result[dependency] = version;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const projectNames = new Set(workspace.projects.map((project) => project.name));
|
|
23
|
+
|
|
24
|
+
for (const [dependencyName, dependencyVersion] of Object.entries(result)) {
|
|
25
|
+
if (dependencyName === TEMPLATE_PACKAGE_NAME) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const installedDependency = workspace.allDependencies.find(
|
|
30
|
+
(dependency) => dependencyName === dependency.name,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// if the dependency is already installed in the workspace, we might want to use that existing version
|
|
34
|
+
if (installedDependency) {
|
|
35
|
+
const version = [...installedDependency.exactVersions].sort().reverse()[0] as string;
|
|
36
|
+
|
|
37
|
+
// if the dependency is actually a project in the workspace, we use existing version
|
|
38
|
+
if (projectNames.has(dependencyName)) {
|
|
39
|
+
if (semver.prerelease(version)?.length) {
|
|
40
|
+
result[dependencyName] = version;
|
|
41
|
+
} else {
|
|
42
|
+
result[dependencyName] = `^${version}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// we use existing version if its major version is equal or greater than major version recommended by the template
|
|
47
|
+
if (getMajorVersion(version) >= getMajorVersion(dependencyVersion)) {
|
|
48
|
+
if (semver.prerelease(version)?.length) {
|
|
49
|
+
result[dependencyName] = version;
|
|
50
|
+
} else {
|
|
51
|
+
result[dependencyName] = `^${version}`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {type Workspace} from '@jakubmazanec/carson';
|
|
2
|
+
|
|
3
|
+
import {DEVELOPMENT_BRANCH_NAMES} from './constants.js';
|
|
4
|
+
|
|
5
|
+
export function getDevelopmentBranch(workspace: Workspace | Workspace<false>) {
|
|
6
|
+
for (let branch of workspace.repository?.branches ?? []) {
|
|
7
|
+
if (DEVELOPMENT_BRANCH_NAMES.has(branch)) {
|
|
8
|
+
return branch;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {type Workspace} from '@jakubmazanec/carson';
|
|
2
|
+
|
|
3
|
+
import {MAIN_BRANCH_NAMES} from './constants.js';
|
|
4
|
+
|
|
5
|
+
export function getMainBranch(workspace: Workspace | Workspace<false>) {
|
|
6
|
+
for (let branch of workspace.repository?.branches ?? []) {
|
|
7
|
+
if (MAIN_BRANCH_NAMES.has(branch)) {
|
|
8
|
+
return branch;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {type Project, type Workspace} from '@jakubmazanec/carson';
|
|
2
|
+
|
|
3
|
+
export function getReferences(
|
|
4
|
+
workspace: Workspace | Workspace<false>,
|
|
5
|
+
project: Project | Project<false>,
|
|
6
|
+
) {
|
|
7
|
+
let references = [];
|
|
8
|
+
|
|
9
|
+
for (let dependency of workspace.allDependencies) {
|
|
10
|
+
for (let workspaceProject of workspace.projects) {
|
|
11
|
+
if (dependency.name === workspaceProject.name) {
|
|
12
|
+
for (let dependencyProject of dependency.projects) {
|
|
13
|
+
if (dependencyProject.name === project.name) {
|
|
14
|
+
references.push({
|
|
15
|
+
path: `${project.relativePath
|
|
16
|
+
.split('/')
|
|
17
|
+
.map(() => '..')
|
|
18
|
+
.join('/')}/${workspaceProject.relativePath}`,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
references.sort((a, b) => a.path.localeCompare(b.path));
|
|
27
|
+
|
|
28
|
+
return references;
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {type Workspace} from '@jakubmazanec/carson';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
const GIT_REPO_REGEXP = /\/([^/]+?)(\.git)?$/;
|
|
5
|
+
|
|
6
|
+
export function getWorkspaceName(workspace: Workspace | Workspace<false>) {
|
|
7
|
+
if (workspace.packageJson?.name) {
|
|
8
|
+
return workspace.packageJson.name;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
if (workspace.repository?.url) {
|
|
12
|
+
let matches = workspace.repository.url.match(GIT_REPO_REGEXP);
|
|
13
|
+
|
|
14
|
+
if (matches?.[1]) {
|
|
15
|
+
return matches[1];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return path.basename(workspace.path);
|
|
20
|
+
}
|
package/source/main.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './constants.js';
|
|
2
|
+
export * from './getDependencies.js';
|
|
3
|
+
export * from './getDevelopmentBranch.js';
|
|
4
|
+
export * from './getMainBranch.js';
|
|
5
|
+
export * from './getReferences.js';
|
|
6
|
+
export * from './getWorkspaceName.js';
|
|
7
|
+
export {default as lodash} from 'lodash';
|
|
8
|
+
export {default as semver} from 'semver';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: '.eslintrc.cjs'
|
|
3
|
+
strategy: overwrite
|
|
4
|
+
---
|
|
5
|
+
/**
|
|
6
|
+
* DO NOT EDIT!
|
|
7
|
+
* This file was autogenerated by Carson.
|
|
8
|
+
* Changes may cause incorrect behavior and will be lost when the file is regenerated.
|
|
9
|
+
*
|
|
10
|
+
* Run `npx carson update workspace` to regenerate.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
root: true,
|
|
15
|
+
extends: [
|
|
16
|
+
'@jakubmazanec/eslint-config',
|
|
17
|
+
'@jakubmazanec/eslint-config/nodejs',
|
|
18
|
+
'@jakubmazanec/eslint-config/prettier',
|
|
19
|
+
],
|
|
20
|
+
ignorePatterns: <%- JSON.stringify(LINT_IGNORE_PATTERNS, null, 2) %>,
|
|
21
|
+
};
|
|
@@ -3,6 +3,22 @@ to: 'package.json'
|
|
|
3
3
|
strategy: merge
|
|
4
4
|
---
|
|
5
5
|
<%
|
|
6
|
+
let developmentDependencies = getDependencies(
|
|
7
|
+
[
|
|
8
|
+
'@types/node',
|
|
9
|
+
'@vitest/coverage-v8',
|
|
10
|
+
'del-cli',
|
|
11
|
+
'esbuild',
|
|
12
|
+
'eslint',
|
|
13
|
+
'prettier',
|
|
14
|
+
'prettier-plugin-packagejson',
|
|
15
|
+
'typedoc',
|
|
16
|
+
'typedoc-plugin-markdown',
|
|
17
|
+
'typescript',
|
|
18
|
+
'vitest',
|
|
19
|
+
],
|
|
20
|
+
workspace,
|
|
21
|
+
);
|
|
6
22
|
let packageJson = {
|
|
7
23
|
repository: {
|
|
8
24
|
type: 'git',
|
|
@@ -10,25 +26,23 @@ let packageJson = {
|
|
|
10
26
|
},
|
|
11
27
|
type: 'module',
|
|
12
28
|
exports: {
|
|
13
|
-
'.':
|
|
29
|
+
'.': `./${BUILD_DIRECTORY}/main.js`,
|
|
14
30
|
'./package.json': './package.json',
|
|
15
31
|
},
|
|
16
|
-
files: [
|
|
32
|
+
files: [BUILD_DIRECTORY, SOURCE_DIRECTORY, 'templates'],
|
|
17
33
|
scripts: {
|
|
18
|
-
build:
|
|
19
|
-
clean:
|
|
20
|
-
document: 'typedoc --options typedoc.config.cjs',
|
|
21
|
-
|
|
34
|
+
build: `del-cli ${BUILD_DIRECTORY} tsconfig.tsbuildinfo && ${BUILD_TO_ESM_COMMAND} && tsc`,
|
|
35
|
+
clean: `del-cli coverage ${BUILD_DIRECTORY} *.tsbuildinfo`,
|
|
36
|
+
document: 'del-cli docs && typedoc --options typedoc.config.cjs',
|
|
37
|
+
format: FORMAT_COMMAND,
|
|
22
38
|
lint: 'eslint .',
|
|
23
|
-
test:
|
|
39
|
+
test: `del-cli coverage && ${TEST_COMMAND}`,
|
|
24
40
|
typecheck: 'tsc --project tsconfig.typecheck.json',
|
|
25
41
|
},
|
|
26
|
-
devDependencies:
|
|
27
|
-
|
|
28
|
-
},
|
|
29
|
-
packageManager: 'npm@8.19.4',
|
|
42
|
+
devDependencies: developmentDependencies,
|
|
43
|
+
packageManager: 'npm@10.1.0',
|
|
30
44
|
engines: {
|
|
31
|
-
node: '
|
|
45
|
+
node: '^20.8.0',
|
|
32
46
|
},
|
|
33
47
|
};
|
|
34
48
|
-%>
|
|
@@ -2,16 +2,23 @@
|
|
|
2
2
|
to: 'tests/tsconfig.json'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
<%
|
|
6
|
+
let tsconfig = {
|
|
7
|
+
compilerOptions: {
|
|
8
|
+
...TSCONFIG_COMPILER_OPTIONS,
|
|
9
|
+
composite: false,
|
|
10
|
+
noEmit: true,
|
|
10
11
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
include: ['./**/*'],
|
|
13
|
+
references: [{path: '..'}],
|
|
14
|
+
};
|
|
15
|
+
-%>
|
|
16
|
+
//
|
|
17
|
+
// DO NOT EDIT!
|
|
18
|
+
// This file was autogenerated by Carson.
|
|
19
|
+
// Changes may cause incorrect behavior and will be lost when the file is regenerated.
|
|
20
|
+
//
|
|
21
|
+
// Run `npx carson update workspace` to regenerate.
|
|
22
|
+
//
|
|
23
|
+
|
|
24
|
+
<%- JSON.stringify(tsconfig, null, 2) %>
|
|
@@ -2,13 +2,27 @@
|
|
|
2
2
|
to: 'tsconfig.json'
|
|
3
3
|
strategy: overwrite
|
|
4
4
|
---
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
<%
|
|
6
|
+
let tsconfig = lodash.merge(
|
|
7
|
+
{
|
|
8
|
+
compilerOptions: {
|
|
9
|
+
...TSCONFIG_COMPILER_OPTIONS,
|
|
10
|
+
emitDeclarationOnly: true,
|
|
11
|
+
outDir: `./${BUILD_DIRECTORY}`,
|
|
12
|
+
rootDir: `./${SOURCE_DIRECTORY}`,
|
|
13
|
+
},
|
|
14
|
+
include: [`./${SOURCE_DIRECTORY}/**/*`],
|
|
15
|
+
references: getReferences(workspace, project),
|
|
11
16
|
},
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
project.config.overrides?.tsconfig ?? {},
|
|
18
|
+
);
|
|
19
|
+
-%>
|
|
20
|
+
//
|
|
21
|
+
// DO NOT EDIT!
|
|
22
|
+
// This file was autogenerated by Carson.
|
|
23
|
+
// Changes may cause incorrect behavior and will be lost when the file is regenerated.
|
|
24
|
+
//
|
|
25
|
+
// Run `npx carson update workspace` to regenerate.
|
|
26
|
+
//
|
|
27
|
+
|
|
28
|
+
<%- JSON.stringify(tsconfig, null, 2) %>
|
|
@@ -1,14 +1,3 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
strategy: overwrite
|
|
2
|
+
extends: '../library/tsconfig.typecheck.json.ejs'
|
|
4
3
|
---
|
|
5
|
-
{
|
|
6
|
-
"extends": "./tsconfig.json",
|
|
7
|
-
"compilerOptions": {
|
|
8
|
-
"composite": false,
|
|
9
|
-
"emitDeclarationOnly": false,
|
|
10
|
-
"noEmit": true,
|
|
11
|
-
"rootDir": "."
|
|
12
|
-
},
|
|
13
|
-
"include": ["./src/**/*", "./tests/**/*", "./*"]
|
|
14
|
-
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
strategy: overwrite
|
|
2
|
+
extends: '../library/typedoc.config.cjs.ejs'
|
|
4
3
|
---
|
|
5
|
-
module.exports = {
|
|
6
|
-
plugin: 'typedoc-plugin-markdown',
|
|
7
|
-
entryPoints: ['./src/main.ts'],
|
|
8
|
-
out: 'docs',
|
|
9
|
-
readme: 'none',
|
|
10
|
-
githubPages: false,
|
|
11
|
-
hideBreadcrumbs: true,
|
|
12
|
-
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
to: '.eslintrc.cjs'
|
|
3
|
+
strategy: overwrite
|
|
4
|
+
---
|
|
5
|
+
/**
|
|
6
|
+
* DO NOT EDIT!
|
|
7
|
+
* This file was autogenerated by Carson.
|
|
8
|
+
* Changes may cause incorrect behavior and will be lost when the file is regenerated.
|
|
9
|
+
*
|
|
10
|
+
* Run `npx carson update workspace` to regenerate.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
module.exports = {
|
|
14
|
+
root: true,
|
|
15
|
+
extends: [
|
|
16
|
+
'@jakubmazanec/eslint-config',
|
|
17
|
+
'@jakubmazanec/eslint-config/nodejs',
|
|
18
|
+
'@jakubmazanec/eslint-config/prettier',
|
|
19
|
+
],
|
|
20
|
+
ignorePatterns: <%- JSON.stringify(LINT_IGNORE_PATTERNS, null, 2) %>,
|
|
21
|
+
};
|
|
@@ -3,26 +3,44 @@ to: 'package.json'
|
|
|
3
3
|
strategy: merge
|
|
4
4
|
---
|
|
5
5
|
<%
|
|
6
|
-
let
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
let developmentDependencies = getDependencies(
|
|
7
|
+
[
|
|
8
|
+
'@types/node',
|
|
9
|
+
'@vitest/coverage-v8',
|
|
10
|
+
'del-cli',
|
|
11
|
+
'esbuild',
|
|
12
|
+
'eslint',
|
|
13
|
+
'prettier',
|
|
14
|
+
'prettier-plugin-packagejson',
|
|
15
|
+
'typescript',
|
|
16
|
+
'vitest',
|
|
17
|
+
],
|
|
18
|
+
workspace,
|
|
19
|
+
);
|
|
20
|
+
let packageJson = lodash.merge(
|
|
21
|
+
{
|
|
22
|
+
repository: {
|
|
23
|
+
type: 'git',
|
|
24
|
+
directory: project.relativePath,
|
|
25
|
+
},
|
|
26
|
+
type: 'commonjs',
|
|
27
|
+
exports: `./${BUILD_DIRECTORY}/main.js`,
|
|
28
|
+
files: [BUILD_DIRECTORY, SOURCE_DIRECTORY],
|
|
29
|
+
scripts: {
|
|
30
|
+
build: `del-cli ${BUILD_DIRECTORY} tsconfig.tsbuildinfo && ${BUILD_TO_CJS_COMMAND} && tsc`,
|
|
31
|
+
clean: `del-cli coverage ${BUILD_DIRECTORY} *.tsbuildinfo`,
|
|
32
|
+
format: FORMAT_COMMAND,
|
|
33
|
+
lint: 'eslint .',
|
|
34
|
+
test: `del-cli coverage && ${TEST_COMMAND}`,
|
|
35
|
+
typecheck: 'tsc --project tsconfig.typecheck.json',
|
|
36
|
+
},
|
|
37
|
+
devDependencies: developmentDependencies,
|
|
38
|
+
packageManager: 'npm@10.1.0',
|
|
39
|
+
engines: {
|
|
40
|
+
node: '^20.8.0',
|
|
41
|
+
},
|
|
10
42
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
files: ['dist', 'src'],
|
|
14
|
-
scripts: {
|
|
15
|
-
build: 'swc src -d dist && tsc',
|
|
16
|
-
clean: 'del-cli coverage dist *.tsbuildinfo',
|
|
17
|
-
format: 'prettier . --write --ignore-unknown --ignore-path ../../.prettierignore',
|
|
18
|
-
lint: 'eslint .',
|
|
19
|
-
test: 'jest --passWithNoTests',
|
|
20
|
-
typecheck: 'tsc --project tsconfig.typecheck.json',
|
|
21
|
-
},
|
|
22
|
-
packageManager: 'npm@8.19.4',
|
|
23
|
-
engines: {
|
|
24
|
-
node: '>=16.20.0',
|
|
25
|
-
},
|
|
26
|
-
};
|
|
43
|
+
project.config.overrides?.packageJson ?? {},
|
|
44
|
+
);
|
|
27
45
|
-%>
|
|
28
46
|
<%- JSON.stringify(packageJson) %>
|