@cellajs/create-cella 0.0.2 → 0.0.3
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/package.json +1 -1
- package/src/cli.js +6 -0
- package/src/constants.js +8 -0
- package/src/create.js +21 -2
- package/src/index.js +14 -1
- package/src/utils/run-package-manager-command.js +12 -0
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -28,6 +28,11 @@ export const command = new Command(NAME)
|
|
|
28
28
|
'Skip the installation of packages.',
|
|
29
29
|
false,
|
|
30
30
|
)
|
|
31
|
+
.option(
|
|
32
|
+
'--skip-generate',
|
|
33
|
+
'Skip generating SQL files.',
|
|
34
|
+
false,
|
|
35
|
+
)
|
|
31
36
|
.option(
|
|
32
37
|
'--skip-clean',
|
|
33
38
|
'Skip cleaning the `cella` template.',
|
|
@@ -75,6 +80,7 @@ const options = command.opts({
|
|
|
75
80
|
skipClean: false,
|
|
76
81
|
skipGit: false,
|
|
77
82
|
skipInstall: false,
|
|
83
|
+
skipGenerate: false,
|
|
78
84
|
});
|
|
79
85
|
|
|
80
86
|
// Export the CLI configuration for use in other modules
|
package/src/constants.js
CHANGED
|
@@ -3,6 +3,14 @@ export const NAME = 'create-cella'
|
|
|
3
3
|
// URL of the template repository
|
|
4
4
|
export const TEMPLATE_URL = 'github:cellajs/cella';
|
|
5
5
|
|
|
6
|
+
// Import package.json dynamically for version and website information
|
|
7
|
+
import packageJson from '../package.json' with { type: 'json' };
|
|
8
|
+
|
|
9
|
+
// Export version, website and author from package.json
|
|
10
|
+
export const VERSION = packageJson.version;
|
|
11
|
+
export const AUTHOR = packageJson.author;
|
|
12
|
+
export const WEBSITE = packageJson.homepage;
|
|
13
|
+
|
|
6
14
|
// Files or folders to be removed from the template after downloading
|
|
7
15
|
export const TO_REMOVE = [
|
|
8
16
|
'info',
|
package/src/create.js
CHANGED
|
@@ -5,9 +5,9 @@ import colors from 'picocolors';
|
|
|
5
5
|
import { downloadTemplate } from "giget";
|
|
6
6
|
import yoctoSpinner from 'yocto-spinner';
|
|
7
7
|
|
|
8
|
-
import { TEMPLATE_URL} from './constants.js';
|
|
8
|
+
import { TEMPLATE_URL } from './constants.js';
|
|
9
9
|
|
|
10
|
-
import { install } from './utils/run-package-manager-command.js';
|
|
10
|
+
import { install, generate } from './utils/run-package-manager-command.js';
|
|
11
11
|
import { cleanTemplate } from './utils/clean-template.js';
|
|
12
12
|
import { runGitCommand } from './utils/run-git-command.js';
|
|
13
13
|
|
|
@@ -18,6 +18,7 @@ export async function create({
|
|
|
18
18
|
skipInstall,
|
|
19
19
|
skipGit,
|
|
20
20
|
skipClean,
|
|
21
|
+
skipGenerate,
|
|
21
22
|
packageManager,
|
|
22
23
|
}) {
|
|
23
24
|
// Save the original working directory
|
|
@@ -88,6 +89,24 @@ export async function create({
|
|
|
88
89
|
console.info(`${colors.yellow('⚠')} --skip-install > Skip installing dependencies`)
|
|
89
90
|
}
|
|
90
91
|
|
|
92
|
+
// Generate SQL files if the skipGenerate flag is not set
|
|
93
|
+
if (!skipGenerate) {
|
|
94
|
+
const installSpinner = yoctoSpinner({
|
|
95
|
+
text: 'generating SQL files',
|
|
96
|
+
}).start();
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
await generate(packageManager)
|
|
100
|
+
installSpinner.success('SQL files generated');
|
|
101
|
+
} catch (e) {
|
|
102
|
+
console.error(e);
|
|
103
|
+
installSpinner.error('Failed to generate SQL files');
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
} else {
|
|
107
|
+
console.info(`${colors.yellow('⚠')} --skip-generate > Skip generating SQL files`)
|
|
108
|
+
}
|
|
109
|
+
|
|
91
110
|
// Initialize Git repository if skipGit flag is not set
|
|
92
111
|
if (!skipGit) {
|
|
93
112
|
const gitSpinner = yoctoSpinner({
|
package/src/index.js
CHANGED
|
@@ -9,17 +9,29 @@ import { cli } from './cli.js'
|
|
|
9
9
|
import { validateProjectName } from './utils/validate-project-name.js'
|
|
10
10
|
import { isEmptyDirectory } from './utils/is-empty-directory.js'
|
|
11
11
|
import { create } from './create.js'
|
|
12
|
-
import { CELLA_TITLE } from './constants.js'
|
|
12
|
+
import { CELLA_TITLE, VERSION, WEBSITE, AUTHOR } from './constants.js'
|
|
13
13
|
|
|
14
14
|
async function main() {
|
|
15
15
|
console.info(CELLA_TITLE);
|
|
16
16
|
|
|
17
|
+
// Display CLI version and created by information
|
|
18
|
+
console.info();
|
|
19
|
+
console.info(`Cella CLI: ${VERSION}`);
|
|
20
|
+
console.info(`Created by: ${AUTHOR}`);
|
|
21
|
+
console.info(`Website: ${WEBSITE}`);
|
|
22
|
+
console.info();
|
|
23
|
+
|
|
17
24
|
// Skip creating a new branch if --skipNewBranch flag is provided or git is skipped
|
|
18
25
|
if (cli.options.skipNewBranch || cli.options.skipGit) {
|
|
19
26
|
cli.createNewBranch = false;
|
|
20
27
|
cli.newBranchName = null;
|
|
21
28
|
}
|
|
22
29
|
|
|
30
|
+
// Skip generating sql files if --skipGenerate flag is provided
|
|
31
|
+
if (cli.options.skipGenerate === true) {
|
|
32
|
+
cli.options.skipGenerate = true;
|
|
33
|
+
}
|
|
34
|
+
|
|
23
35
|
// Skip installing packages if --skipInstall flag is provided
|
|
24
36
|
if (cli.options.skipInstall === true) {
|
|
25
37
|
cli.options.skipInstall = true;
|
|
@@ -95,6 +107,7 @@ async function main() {
|
|
|
95
107
|
skipInstall: cli.options.skipInstall,
|
|
96
108
|
skipGit: cli.options.skipGit,
|
|
97
109
|
skipClean: cli.options.skipClean,
|
|
110
|
+
skipGenerate: cli.options.skipGenerate,
|
|
98
111
|
packageManager: cli.packageManager,
|
|
99
112
|
});
|
|
100
113
|
}
|
|
@@ -53,4 +53,16 @@ export async function install(packageManager) {
|
|
|
53
53
|
return runPackageManagerCommand(packageManager, ['install'], {
|
|
54
54
|
NODE_ENV: 'development',
|
|
55
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
|
+
});
|
|
56
68
|
}
|