@erwininteractive/mvc 0.1.1 → 0.1.2
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
CHANGED
|
@@ -8,6 +8,17 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const child_process_1 = require("child_process");
|
|
10
10
|
const paths_1 = require("./paths");
|
|
11
|
+
// Get version from package.json
|
|
12
|
+
function getFrameworkVersion() {
|
|
13
|
+
try {
|
|
14
|
+
const pkgPath = path_1.default.join((0, paths_1.getPackageRoot)(), "package.json");
|
|
15
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(pkgPath, "utf-8"));
|
|
16
|
+
return pkg.version || "0.1.1";
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return "0.1.1";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
11
22
|
/**
|
|
12
23
|
* Scaffold a new MVC application.
|
|
13
24
|
*/
|
|
@@ -21,21 +32,24 @@ async function initApp(dir, options = {}) {
|
|
|
21
32
|
}
|
|
22
33
|
// Copy app scaffold templates
|
|
23
34
|
copyDirRecursive(templateDir, targetDir);
|
|
35
|
+
// Rename dotfiles (npm doesn't publish .gitignore, so we use gitignore.txt)
|
|
36
|
+
const gitignoreSrc = path_1.default.join(targetDir, "gitignore.txt");
|
|
37
|
+
const gitignoreDest = path_1.default.join(targetDir, ".gitignore");
|
|
38
|
+
if (fs_1.default.existsSync(gitignoreSrc)) {
|
|
39
|
+
fs_1.default.renameSync(gitignoreSrc, gitignoreDest);
|
|
40
|
+
}
|
|
24
41
|
// Copy .env.example
|
|
25
42
|
const envExample = (0, paths_1.getEnvExamplePath)();
|
|
26
43
|
if (fs_1.default.existsSync(envExample)) {
|
|
27
44
|
fs_1.default.copyFileSync(envExample, path_1.default.join(targetDir, ".env.example"));
|
|
28
45
|
}
|
|
29
|
-
// Update package.json with app name and framework
|
|
46
|
+
// Update package.json with app name and framework version
|
|
30
47
|
const appPackageJson = path_1.default.join(targetDir, "package.json");
|
|
31
48
|
if (fs_1.default.existsSync(appPackageJson)) {
|
|
32
49
|
const pkg = JSON.parse(fs_1.default.readFileSync(appPackageJson, "utf-8"));
|
|
33
50
|
pkg.name = path_1.default.basename(dir);
|
|
34
|
-
// Use
|
|
35
|
-
|
|
36
|
-
const frameworkRoot = (0, paths_1.getPackageRoot)();
|
|
37
|
-
const relativePath = path_1.default.relative(targetDir, frameworkRoot);
|
|
38
|
-
pkg.dependencies["@erwininteractive/mvc"] = `file:${relativePath}`;
|
|
51
|
+
// Use npm package version (not file path)
|
|
52
|
+
pkg.dependencies["@erwininteractive/mvc"] = `^${getFrameworkVersion()}`;
|
|
39
53
|
fs_1.default.writeFileSync(appPackageJson, JSON.stringify(pkg, null, 2));
|
|
40
54
|
}
|
|
41
55
|
console.log("Application scaffolded successfully!");
|
package/package.json
CHANGED