@dolphjs/cli 1.1.15 → 1.1.16
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.
|
@@ -22,6 +22,8 @@ export const addControllerInComponentFIle = (componentName) => {
|
|
|
22
22
|
try {
|
|
23
23
|
if (!existsSync(componentPath)) {
|
|
24
24
|
const fileContent = `import { Component } from "@dolphjs/dolph/decorators";
|
|
25
|
+
import { ${capitalizedString}Controller } from "./${componentName}/${componentName}.controller";
|
|
26
|
+
|
|
25
27
|
@Component({ controllers: [${capitalizedString}Controller] })
|
|
26
28
|
export class ${capitalizedString}Component {}
|
|
27
29
|
`;
|
|
@@ -31,8 +33,16 @@ export class ${capitalizedString}Component {}
|
|
|
31
33
|
const fileContent = readFileSync(componentPath, "utf8");
|
|
32
34
|
const newComponentInstance = `${capitalizedString}Controller`;
|
|
33
35
|
if (!fileContent.includes(importStatement)) {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
+
const controllersArrayMatch = fileContent.match(/@Component\(\s*{\s*controllers:\s*\[([^\]]*)\]\s*}\s*\)/);
|
|
37
|
+
if (controllersArrayMatch) {
|
|
38
|
+
const existingCode = controllersArrayMatch[1].trim();
|
|
39
|
+
let fileContents;
|
|
40
|
+
fileContents = fileContent.replace(existingCode, `${existingCode.length > 0
|
|
41
|
+
? existingCode.slice(0, -1) + `, ${newComponentInstance}`
|
|
42
|
+
: newComponentInstance}`);
|
|
43
|
+
const updatedContents = `${importStatement}\n${fileContents}`;
|
|
44
|
+
writeFileSync(componentPath, updatedContents);
|
|
45
|
+
}
|
|
36
46
|
}
|
|
37
47
|
if (fileContent.includes(`const dolph`)) {
|
|
38
48
|
// add new controller class to the existing array
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dolphjs/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
4
4
|
"description": "The dolphjs-cli is a tool for efficient intialization and management of a dolphjs project",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"repository": "https://github.com/dolphjs/dolph-cli.git",
|