boilerforge 1.0.2 → 1.2.0-dev.1
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/dist/cli.js +13583 -993
- package/dist/templates/create-simple-app/package.json.hbs +30 -0
- package/dist/templates/create-simple-app/src/index.js.hbs +5 -0
- package/dist/templates/create-simple-app/src/index.ts.hbs +5 -0
- package/dist/templates/create-simple-app/tsconfig.json.hbs +14 -0
- package/package.json +27 -14
- package/{src/templates/create-node-app/resource/gitignore.ts → templates/create-simple-app/.gitignore.hbs} +1 -14
- package/templates/create-simple-app/.prettierrc.json.hbs +15 -0
- package/templates/create-simple-app/eslint.config.mjs.hbs +23 -0
- package/templates/create-simple-app/package.json.hbs +30 -0
- package/templates/create-simple-app/src/index.js.hbs +5 -0
- package/templates/create-simple-app/src/index.ts.hbs +5 -0
- package/templates/create-simple-app/tsconfig.json.hbs +14 -0
- package/.commitlintrc.json +0 -3
- package/.github/workflows/auto-pr-gen.yml +0 -25
- package/.github/workflows/enforce-pr-rules.yml +0 -28
- package/.github/workflows/npm-publish.yml +0 -17
- package/.github/workflows/release-changelog.yml +0 -28
- package/.husky/commit-msg +0 -4
- package/.husky/pre-push +0 -4
- package/.release-please-manifest.json +0 -3
- package/CHANGELOG.md +0 -37
- package/bin/cli.ts +0 -21
- package/esbuild.config.ts +0 -17
- package/prettier.config.mjs +0 -20
- package/release-please-config.json +0 -15
- package/src/config/cli-config.ts +0 -25
- package/src/lib/file.ts +0 -159
- package/src/lib/project.ts +0 -211
- package/src/lib/prompter.ts +0 -201
- package/src/lib/task.ts +0 -41
- package/src/templates/create-node-app/index.ts +0 -306
- package/src/templates/create-node-app/resource/editor-config.ts +0 -24
- package/src/templates/create-node-app/resource/eslint.ts +0 -62
- package/src/templates/create-node-app/resource/package-json.ts +0 -57
- package/src/templates/create-node-app/resource/prettier.ts +0 -45
- package/src/templates/create-node-app/resource/project-deps.ts +0 -30
- package/src/templates/create-node-app/resource/project-files.ts +0 -17
- package/src/templates/create-node-app/resource/tsconfig.ts +0 -20
- package/src/templates/index.ts +0 -1
- package/src/templates/utils/badges.ts +0 -13
- package/src/templates/utils/git.ts +0 -64
- package/src/templates/utils/package-manager.ts +0 -78
- package/src/templates/utils/readme.ts +0 -115
- package/src/utils/exec-cmd.ts +0 -80
- package/src/utils/index.ts +0 -60
- package/src/utils/logger.ts +0 -24
- package/tsconfig.json +0 -17
- /package/{eslint.config.mjs → dist/templates/create-simple-app/eslint.config.mjs.hbs} +0 -0
- /package/{.editorconfig → templates/create-simple-app/.editorconfig.hbs} +0 -0
- /package/{.prettierignore → templates/create-simple-app/.prettierignore.hbs} +0 -0
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { ProjectDependency } from '../../lib/project';
|
|
2
|
-
import { execCmd, ExecCmdError } from '../../utils/exec-cmd';
|
|
3
|
-
import { logger } from '../../utils/logger';
|
|
4
|
-
|
|
5
|
-
export enum PackageManager {
|
|
6
|
-
YARN = 'yarn',
|
|
7
|
-
NPM = 'npm',
|
|
8
|
-
PNPM = 'pnpm',
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const getPackageManagerVersion = async (
|
|
12
|
-
packageManager: string,
|
|
13
|
-
): Promise<string | undefined> => {
|
|
14
|
-
try {
|
|
15
|
-
const { stdout: packageManagerVersion = '' } =
|
|
16
|
-
(await execCmd(`${packageManager} --version`)) ?? {};
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
packageManagerVersion.match(/(?=(\d+.\d+.\d+))/)?.[1] ?? undefined
|
|
20
|
-
);
|
|
21
|
-
} catch (error) {
|
|
22
|
-
const { code, message } = error as ExecCmdError;
|
|
23
|
-
|
|
24
|
-
if (code === 'ENOENT') return undefined;
|
|
25
|
-
|
|
26
|
-
logger.err(
|
|
27
|
-
`Error while checking if ${packageManager} exists, Code: ${code} | Message: ${message}`,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
throw new Error(
|
|
31
|
-
`${getPackageManagerVersion.name} error, Code: ${code} | Message: ${message}`,
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const installDependencies = async (
|
|
37
|
-
projectDir: string,
|
|
38
|
-
packageManager: string,
|
|
39
|
-
projectDeps: ProjectDependency,
|
|
40
|
-
) => {
|
|
41
|
-
try {
|
|
42
|
-
const { dependencies, devDependencies } = projectDeps;
|
|
43
|
-
|
|
44
|
-
const cmdForInstall =
|
|
45
|
-
packageManager === PackageManager.YARN ? 'add' : 'install';
|
|
46
|
-
|
|
47
|
-
const devDepsCmd = `${packageManager} ${cmdForInstall} -D ${devDependencies.join(' ')}`;
|
|
48
|
-
|
|
49
|
-
devDependencies.length &&
|
|
50
|
-
(await execCmd(devDepsCmd, { cwd: projectDir }));
|
|
51
|
-
|
|
52
|
-
dependencies.length &&
|
|
53
|
-
(await execCmd(
|
|
54
|
-
`${packageManager} ${cmdForInstall} ${dependencies.join(' ')}`,
|
|
55
|
-
{ cwd: projectDir },
|
|
56
|
-
));
|
|
57
|
-
} catch (error) {
|
|
58
|
-
const { code, message } = error as ExecCmdError;
|
|
59
|
-
|
|
60
|
-
logger.err(
|
|
61
|
-
`Error while installing node dependencies ${packageManager}, Code: ${code} | Message: ${message}`,
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
throw new Error(
|
|
65
|
-
`${installDependencies.name} error, Code: ${code} | Message: ${message}`,
|
|
66
|
-
);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const getLockFileName = (packageManager: string): string | undefined => {
|
|
71
|
-
const lockFileMap: Record<string, string> = {
|
|
72
|
-
[PackageManager.YARN]: 'yarn.lock',
|
|
73
|
-
[PackageManager.NPM]: 'package-lock.json',
|
|
74
|
-
[PackageManager.PNPM]: 'pnpm-lock.yaml',
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return lockFileMap[packageManager];
|
|
78
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import remarkStringify from 'remark-stringify';
|
|
2
|
-
import { Root } from 'remark-stringify/lib';
|
|
3
|
-
import { unified } from 'unified';
|
|
4
|
-
import { u } from 'unist-builder';
|
|
5
|
-
import { NodejsProject, Resource } from '../../lib/project';
|
|
6
|
-
import { Badge } from './badges';
|
|
7
|
-
import { PackageManager } from './package-manager';
|
|
8
|
-
|
|
9
|
-
const createBadgeNode = (alt: string, url: string, title?: string) =>
|
|
10
|
-
u('paragraph', [
|
|
11
|
-
u('image', {
|
|
12
|
-
url,
|
|
13
|
-
alt,
|
|
14
|
-
title: title || alt,
|
|
15
|
-
}),
|
|
16
|
-
]);
|
|
17
|
-
|
|
18
|
-
const generateReadMeContent = (project: NodejsProject): string => {
|
|
19
|
-
const {
|
|
20
|
-
name: projectName,
|
|
21
|
-
description,
|
|
22
|
-
packageManager,
|
|
23
|
-
enabledTypescript,
|
|
24
|
-
enabledEslintPrettier,
|
|
25
|
-
} = project;
|
|
26
|
-
|
|
27
|
-
const installDepsCommand =
|
|
28
|
-
packageManager === PackageManager.YARN
|
|
29
|
-
? packageManager
|
|
30
|
-
: `${packageManager} install`;
|
|
31
|
-
|
|
32
|
-
const versionBadge = createBadgeNode(
|
|
33
|
-
'version',
|
|
34
|
-
`https://img.shields.io/badge/version-${project.version}-green.svg`,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const techBadges = [
|
|
38
|
-
'nodejs',
|
|
39
|
-
project.packageManager,
|
|
40
|
-
enabledTypescript ? 'typescript' : 'javascript',
|
|
41
|
-
...(enabledEslintPrettier ? ['eslint', 'prettier'] : []),
|
|
42
|
-
].map((tech) => createBadgeNode(tech, Badge[tech.toUpperCase()]));
|
|
43
|
-
|
|
44
|
-
const readmeAst = u('root', [
|
|
45
|
-
u('heading', { depth: 1 }, [u('text', `🚀 ${projectName}`)]),
|
|
46
|
-
|
|
47
|
-
u('paragraph', versionBadge),
|
|
48
|
-
|
|
49
|
-
...(description.length
|
|
50
|
-
? [
|
|
51
|
-
u('heading', { depth: 2 }, [u('text', '📖 About Project')]),
|
|
52
|
-
u('paragraph', [u('text', description)]),
|
|
53
|
-
]
|
|
54
|
-
: []),
|
|
55
|
-
|
|
56
|
-
u('heading', { depth: 3 }, [u('text', 'Built With')]),
|
|
57
|
-
|
|
58
|
-
u('heading', { depth: 4 }, techBadges),
|
|
59
|
-
|
|
60
|
-
u('heading', { depth: 3 }, [u('text', '🛠️ Installation')]),
|
|
61
|
-
|
|
62
|
-
u('heading', { depth: 4 }, [
|
|
63
|
-
u('text', 'Navigate into the project directory'),
|
|
64
|
-
]),
|
|
65
|
-
u('code', { lang: '' }, `cd ${projectName}`),
|
|
66
|
-
|
|
67
|
-
u('heading', { depth: 4 }, [u('text', 'Install dependencies')]),
|
|
68
|
-
u('code', { lang: '' }, installDepsCommand),
|
|
69
|
-
|
|
70
|
-
u('heading', { depth: 3 }, [u('text', '▶️ Running the App')]),
|
|
71
|
-
|
|
72
|
-
...(enabledTypescript
|
|
73
|
-
? [
|
|
74
|
-
u('heading', { depth: 4 }, [
|
|
75
|
-
u('text', 'To start the app in development mode:'),
|
|
76
|
-
]),
|
|
77
|
-
u('code', { lang: '' }, `${packageManager} run dev`),
|
|
78
|
-
]
|
|
79
|
-
: []),
|
|
80
|
-
|
|
81
|
-
u('paragraph', [u('text', 'To start the app in production mode:')]),
|
|
82
|
-
|
|
83
|
-
...(enabledTypescript
|
|
84
|
-
? [
|
|
85
|
-
u('list', { ordered: false }, [
|
|
86
|
-
u('listItem', [
|
|
87
|
-
u('paragraph', [u('text', 'Build the project')]),
|
|
88
|
-
u(
|
|
89
|
-
'code',
|
|
90
|
-
{ lang: '' },
|
|
91
|
-
`${packageManager} run build`,
|
|
92
|
-
),
|
|
93
|
-
]),
|
|
94
|
-
u('listItem', [
|
|
95
|
-
u('paragraph', [u('text', 'Run app in production')]),
|
|
96
|
-
u(
|
|
97
|
-
'code',
|
|
98
|
-
{ lang: '' },
|
|
99
|
-
`${packageManager} run start`,
|
|
100
|
-
),
|
|
101
|
-
]),
|
|
102
|
-
]),
|
|
103
|
-
]
|
|
104
|
-
: [u('code', { lang: '' }, `${packageManager} run start`)]),
|
|
105
|
-
]);
|
|
106
|
-
|
|
107
|
-
return unified()
|
|
108
|
-
.use(remarkStringify)
|
|
109
|
-
.stringify(readmeAst as Root);
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const getReadmeContent = (project: NodejsProject): Resource => ({
|
|
113
|
-
filename: 'README.md',
|
|
114
|
-
content: generateReadMeContent(project),
|
|
115
|
-
});
|
package/src/utils/exec-cmd.ts
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { $, ExecaError, Result } from 'execa';
|
|
2
|
-
|
|
3
|
-
export type ExecCmdProps = {
|
|
4
|
-
cwd?: string;
|
|
5
|
-
throwError?: boolean;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export type ExecCmdErrorProps = {
|
|
9
|
-
code?: string;
|
|
10
|
-
command: string;
|
|
11
|
-
message: string;
|
|
12
|
-
errorName: string;
|
|
13
|
-
stack?: string;
|
|
14
|
-
cause: unknown;
|
|
15
|
-
shortMessage: string;
|
|
16
|
-
originalMessage: string;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export class ExecCmdError implements Error {
|
|
20
|
-
name: string;
|
|
21
|
-
message: string;
|
|
22
|
-
stack?: string | undefined;
|
|
23
|
-
cause: unknown;
|
|
24
|
-
shortMessage: string;
|
|
25
|
-
originalMessage: string;
|
|
26
|
-
errorName: string;
|
|
27
|
-
command: string;
|
|
28
|
-
code?: string;
|
|
29
|
-
|
|
30
|
-
constructor(execCmdErrorProps: ExecCmdErrorProps) {
|
|
31
|
-
this.name = 'ExecCmdError';
|
|
32
|
-
this.message = execCmdErrorProps.message;
|
|
33
|
-
this.cause = execCmdErrorProps.cause;
|
|
34
|
-
this.stack = execCmdErrorProps.stack;
|
|
35
|
-
this.shortMessage = execCmdErrorProps.shortMessage;
|
|
36
|
-
this.originalMessage = execCmdErrorProps.originalMessage;
|
|
37
|
-
this.errorName = execCmdErrorProps.errorName;
|
|
38
|
-
this.command = execCmdErrorProps.command;
|
|
39
|
-
this.code = execCmdErrorProps.code;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const execCmd = async (
|
|
44
|
-
command: string,
|
|
45
|
-
execCmdProps?: ExecCmdProps,
|
|
46
|
-
): Promise<Result<{}> | undefined> => {
|
|
47
|
-
const { cwd = '', throwError = true } = execCmdProps ?? {};
|
|
48
|
-
|
|
49
|
-
try {
|
|
50
|
-
const $cmdExecutor = $.s({
|
|
51
|
-
...(cwd?.length ? { cwd } : {}),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return $cmdExecutor`${command.trim().split(' ')}`;
|
|
55
|
-
} catch (error) {
|
|
56
|
-
if (!throwError) return;
|
|
57
|
-
|
|
58
|
-
const {
|
|
59
|
-
message,
|
|
60
|
-
cause,
|
|
61
|
-
stack,
|
|
62
|
-
shortMessage,
|
|
63
|
-
originalMessage,
|
|
64
|
-
name: errorName,
|
|
65
|
-
command,
|
|
66
|
-
code,
|
|
67
|
-
} = error as ExecaError;
|
|
68
|
-
|
|
69
|
-
throw new ExecCmdError({
|
|
70
|
-
message,
|
|
71
|
-
cause,
|
|
72
|
-
stack,
|
|
73
|
-
shortMessage,
|
|
74
|
-
originalMessage,
|
|
75
|
-
errorName,
|
|
76
|
-
command,
|
|
77
|
-
code,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
};
|
package/src/utils/index.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, rmSync } from 'fs';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
|
|
4
|
-
import { logger } from './logger';
|
|
5
|
-
|
|
6
|
-
export const Regex = {
|
|
7
|
-
PROJECT_NAME: /^[a-zA-Z][a-zA-Z0-9-]*$/,
|
|
8
|
-
VERSION:
|
|
9
|
-
/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+([0-9A-Za-z.-]+))?$/,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export namespace DirectoryUtils {
|
|
13
|
-
export type RemoveDirectoryOptions = {
|
|
14
|
-
recursive: boolean;
|
|
15
|
-
errorIfNotExists: boolean;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const create = (dir: string, parentDirPath: string = __dirname) => {
|
|
19
|
-
const dirPath = join(parentDirPath, dir);
|
|
20
|
-
try {
|
|
21
|
-
if (existsSync(dirPath)) return;
|
|
22
|
-
|
|
23
|
-
mkdirSync(dirPath, { recursive: true });
|
|
24
|
-
} catch (error) {
|
|
25
|
-
logger.err(
|
|
26
|
-
`Error while creating the directory: ${dirPath}, ${(error as Error).message}`,
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
throw new Error(`Error while creating the directory ${dirPath}`);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export const remove = (
|
|
34
|
-
relativeDirPath: string,
|
|
35
|
-
parentDirPath: string = __dirname,
|
|
36
|
-
removeDirectoryOptions: Partial<RemoveDirectoryOptions> = {
|
|
37
|
-
recursive: false,
|
|
38
|
-
errorIfNotExists: false,
|
|
39
|
-
},
|
|
40
|
-
) => {
|
|
41
|
-
const { recursive, errorIfNotExists } = removeDirectoryOptions;
|
|
42
|
-
|
|
43
|
-
const dirPath = join(parentDirPath, relativeDirPath);
|
|
44
|
-
try {
|
|
45
|
-
const dirExists = existsSync(dirPath);
|
|
46
|
-
if (!dirExists && errorIfNotExists)
|
|
47
|
-
throw new Error(`Error directory does not exists: ${dirPath}`);
|
|
48
|
-
|
|
49
|
-
if (!dirExists && !errorIfNotExists) return;
|
|
50
|
-
|
|
51
|
-
rmSync(dirPath, { recursive, force: !errorIfNotExists });
|
|
52
|
-
} catch (error) {
|
|
53
|
-
logger.err(
|
|
54
|
-
`Error while removing the directory: ${dirPath}, ${(error as Error).message}`,
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
throw new Error(`Error while removing the directory ${dirPath}`);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
package/src/utils/logger.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Class for logger
|
|
2
|
-
class Logger {
|
|
3
|
-
static log(...data: unknown[]) {
|
|
4
|
-
console.log(...data);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
static warn(...data: unknown[]) {
|
|
8
|
-
console.warn(...data);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
static err(...data: unknown[]) {
|
|
12
|
-
console.error(...data);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
static critical(...data: unknown[]) {
|
|
16
|
-
console.error(...data);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static info(...data: unknown[]) {
|
|
20
|
-
console.info(...data);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const logger = Logger;
|
package/tsconfig.json
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2024", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
4
|
-
/* Modules */
|
|
5
|
-
"module": "commonjs", /* Specify what module code is generated. */
|
|
6
|
-
/* Emit */
|
|
7
|
-
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
8
|
-
/* Interop Constraints */
|
|
9
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
10
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
11
|
-
/* Type Checking */
|
|
12
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
13
|
-
/* Completeness */
|
|
14
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
15
|
-
},
|
|
16
|
-
"include": ["bin/**/*.ts", "src/**/*.ts"]
|
|
17
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|