@cellajs/create-cella 0.0.5 → 0.0.7
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/index.ts +3 -0
- package/package.json +10 -6
- package/src/add-remote.ts +55 -0
- package/src/cli.ts +107 -0
- package/src/constants.ts +43 -0
- package/src/create.ts +183 -0
- package/src/{index.js → index.ts} +31 -17
- package/src/utils/clean-template.ts +111 -0
- package/src/utils/is-empty-directory.ts +15 -0
- package/src/utils/package-json.ts +25 -0
- package/src/utils/run-git-command.ts +57 -0
- package/src/utils/run-package-manager-command.ts +74 -0
- package/src/utils/validate-project-name.ts +22 -0
- package/LICENSE +0 -21
- package/index.js +0 -3
- package/src/cli.js +0 -94
- package/src/constants.js +0 -39
- package/src/create.js +0 -168
- package/src/utils/clean-template.js +0 -99
- package/src/utils/is-empty-directory.js +0 -15
- package/src/utils/package-json.js +0 -22
- package/src/utils/run-git-command.js +0 -39
- package/src/utils/run-package-manager-command.js +0 -68
- package/src/utils/validate-project-name.js +0 -28
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import spawn from 'cross-spawn'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Executes a command using the specified package manager (e.g., pnpm).
|
|
5
|
-
*
|
|
6
|
-
* @param {string} packageManager - The package manager to use (e.g., 'pnpm').
|
|
7
|
-
* @param {Array<string>} args - The arguments to pass to the package manager command.
|
|
8
|
-
* @param {Object} [env={}] - Additional environment variables to set during command execution.
|
|
9
|
-
* @returns {Promise<void>} - A promise that resolves if the command executes successfully; otherwise, it rejects with an error message.
|
|
10
|
-
*/
|
|
11
|
-
export async function runPackageManagerCommand(packageManager, args, env = {} ) {
|
|
12
|
-
return new Promise((resolve, reject) => {
|
|
13
|
-
const child = spawn(packageManager, args, {
|
|
14
|
-
env: {
|
|
15
|
-
...process.env,
|
|
16
|
-
...env,
|
|
17
|
-
},
|
|
18
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
// Buffer for capturing stderr and stdout output
|
|
22
|
-
let stderrBuffer = ''
|
|
23
|
-
let stdoutBuffer = ''
|
|
24
|
-
|
|
25
|
-
// Capture stderr output
|
|
26
|
-
child.stderr?.on('data', (data) => {
|
|
27
|
-
stderrBuffer += data
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Capture stdout output
|
|
31
|
-
child.stdout?.on('data', (data) => {
|
|
32
|
-
stdoutBuffer += data
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Handle process exit
|
|
36
|
-
child.on('close', (code) => {
|
|
37
|
-
if (code !== 0) {
|
|
38
|
-
reject(`"${packageManager} ${args.join(' ')}" failed ${stdoutBuffer} ${stderrBuffer}` );
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
resolve();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Installs dependencies using the specified package manager.
|
|
48
|
-
*
|
|
49
|
-
* @param {string} packageManager - The package manager to use for installation (e.g., ''pnpm').
|
|
50
|
-
* @returns {Promise<void>} - A promise that resolves if the installation completes successfully; otherwise, it rejects with an error.
|
|
51
|
-
*/
|
|
52
|
-
export async function install(packageManager) {
|
|
53
|
-
return runPackageManagerCommand(packageManager, ['install'], {
|
|
54
|
-
NODE_ENV: 'development',
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Generates sql files using the specified package manager.
|
|
60
|
-
*
|
|
61
|
-
* @param {string} packageManager - The package manager to use for generation (e.g., 'pnpm').
|
|
62
|
-
* @returns {Promise<void>} - A promise that resolves if the generation completes successfully; otherwise, it rejects with an error.
|
|
63
|
-
*/
|
|
64
|
-
export async function generate (packageManager) {
|
|
65
|
-
return runPackageManagerCommand(packageManager, ['generate'], {
|
|
66
|
-
NODE_ENV: 'development',
|
|
67
|
-
});
|
|
68
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import validate from 'validate-npm-package-name'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Validates a project name according to npm package naming conventions.
|
|
5
|
-
*
|
|
6
|
-
* @param {string} name - The name of the project to validate.
|
|
7
|
-
* @returns {Object} - An object containing the validation result and any associated problems.
|
|
8
|
-
* @returns {boolean} return.valid - Indicates if the project name is valid.
|
|
9
|
-
* @returns {Array<string>} return.problems - A list of errors and warnings associated with the project name.
|
|
10
|
-
*/
|
|
11
|
-
export function validateProjectName(name) {
|
|
12
|
-
// Validate the project name
|
|
13
|
-
const nameValidation = validate(name);
|
|
14
|
-
|
|
15
|
-
// If the name is valid for new packages, return valid status
|
|
16
|
-
if (nameValidation.validForNewPackages) {
|
|
17
|
-
return { valid: true, problems: [] };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Return validation result with errors and warnings
|
|
21
|
-
return {
|
|
22
|
-
valid: false,
|
|
23
|
-
problems: [
|
|
24
|
-
...(nameValidation.errors || []),
|
|
25
|
-
...(nameValidation.warnings || []),
|
|
26
|
-
],
|
|
27
|
-
}
|
|
28
|
-
}
|