@flutry/cli 1.0.12 → 1.0.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/dist/commands/generate.js +1 -17
- package/package.json +1 -1
|
@@ -22,7 +22,7 @@ function normalizeName(name) {
|
|
|
22
22
|
}
|
|
23
23
|
function routeTemplate(className, fileName) {
|
|
24
24
|
return [
|
|
25
|
-
"import Router from '../../package/router
|
|
25
|
+
"import { Router } from '../../package/router';",
|
|
26
26
|
'',
|
|
27
27
|
`export default class ${className}Route extends Router {`,
|
|
28
28
|
' constructor() {',
|
|
@@ -90,24 +90,8 @@ async function writeNewFile(filePath, content) {
|
|
|
90
90
|
await fs_1.promises.mkdir(path_1.default.dirname(filePath), { recursive: true });
|
|
91
91
|
await fs_1.promises.writeFile(filePath, content, 'utf8');
|
|
92
92
|
}
|
|
93
|
-
async function isFlutryProject(projectRoot) {
|
|
94
|
-
try {
|
|
95
|
-
await Promise.all([
|
|
96
|
-
fs_1.promises.access(path_1.default.join(projectRoot, 'package.json')),
|
|
97
|
-
fs_1.promises.access(path_1.default.join(projectRoot, 'src', 'package', 'router', 'router.ts')),
|
|
98
|
-
]);
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
catch {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
93
|
async function generate(type, name) {
|
|
106
94
|
const projectRoot = process.cwd();
|
|
107
|
-
if (!(await isFlutryProject(projectRoot))) {
|
|
108
|
-
console.error('This command can only be used inside a Flutry project.');
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
95
|
const { fileName, className } = normalizeName(name);
|
|
112
96
|
const sourceRoot = path_1.default.join(projectRoot, 'src');
|
|
113
97
|
const spinner = (0, ora_1.default)({
|