create-modoock-app 2.2.0 → 2.3.0

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
@@ -1,110 +1,28 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
3
  Object.defineProperty(exports, "__esModule", { value: true });
7
- const node_fs_1 = __importDefault(require("node:fs"));
8
- const node_path_1 = __importDefault(require("node:path"));
9
- const node_child_process_1 = require("node:child_process");
10
- const MODOOCK_PACKAGES = [
11
- "@modoock/components",
12
- "@modoock/knowledge-base",
13
- ];
14
- function copyDirectory(source, destination) {
15
- node_fs_1.default.mkdirSync(destination, { recursive: true });
16
- for (const entry of node_fs_1.default.readdirSync(source, {
17
- withFileTypes: true,
18
- })) {
19
- const sourcePath = node_path_1.default.join(source, entry.name);
20
- const destinationPath = node_path_1.default.join(destination, entry.name);
21
- if (entry.isDirectory()) {
22
- copyDirectory(sourcePath, destinationPath);
23
- }
24
- else {
25
- node_fs_1.default.copyFileSync(sourcePath, destinationPath);
26
- }
27
- }
28
- }
29
- function getLatestVersion(packageName) {
30
- try {
31
- const version = (0, node_child_process_1.execSync)(`npm view ${packageName} version`, {
32
- encoding: "utf8",
33
- stdio: ["ignore", "pipe", "pipe"],
34
- }).trim();
35
- if (!version) {
36
- throw new Error(`No stable version found for ${packageName}.`);
37
- }
38
- return version;
39
- }
40
- catch {
41
- throw new Error(`Could not resolve the latest stable version of ${packageName}.`);
42
- }
43
- }
44
- function getLatestModoockDependencies() {
45
- const dependencies = {};
46
- for (const packageName of MODOOCK_PACKAGES) {
47
- console.log(`Resolving latest ${packageName}...`);
48
- const version = getLatestVersion(packageName);
49
- dependencies[packageName] = version;
50
- console.log(` ${packageName}@${version}`);
51
- }
52
- return dependencies;
53
- }
54
- function updateProjectPackageJson(targetDirectory) {
55
- const packageJsonPath = node_path_1.default.join(targetDirectory, "package.json");
56
- const packageJson = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, "utf8"));
57
- packageJson.name =
58
- node_path_1.default.basename(targetDirectory);
59
- const modoockDependencies = getLatestModoockDependencies();
60
- packageJson.dependencies = {
61
- ...(packageJson.dependencies ?? {}),
62
- ...modoockDependencies,
63
- };
64
- node_fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
65
- }
66
- function installDependencies(targetDirectory) {
67
- console.log("");
68
- console.log("Installing dependencies...");
69
- try {
70
- (0, node_child_process_1.execSync)("npm install", {
71
- cwd: targetDirectory,
72
- stdio: "inherit",
73
- });
74
- }
75
- catch {
76
- throw new Error("Failed to install project dependencies.");
77
- }
78
- }
79
- function main() {
80
- const projectName = process.argv[2];
81
- if (!projectName) {
82
- console.error("Usage: npx create-modoock-app <project-name>");
83
- process.exit(1);
84
- }
85
- const targetDirectory = node_path_1.default.resolve(process.cwd(), projectName);
86
- if (node_fs_1.default.existsSync(targetDirectory)) {
87
- console.error(`Error: Directory "${projectName}" already exists.`);
4
+ const create_1 = require("./commands/create");
5
+ const init_1 = require("./commands/init");
6
+ const update_1 = require("./commands/update");
7
+ async function main() {
8
+ const command = process.argv[2];
9
+ if (!command) {
10
+ console.error("Usage:");
11
+ console.error(" npx create-modoock-app <project-name>");
12
+ console.error(" npx create-modoock-app init");
13
+ console.error(" npx create-modoock-app update");
88
14
  process.exit(1);
89
15
  }
90
- const packageRoot = node_path_1.default.resolve(__dirname, "..");
91
- const templateDirectory = node_path_1.default.join(packageRoot, "template");
92
- console.log(`Creating Modooock project: ${node_path_1.default.basename(targetDirectory)}`);
93
16
  try {
94
- // Copy the project foundation.
95
- copyDirectory(templateDirectory, targetDirectory);
96
- // Configure the generated project.
97
- updateProjectPackageJson(targetDirectory);
98
- // Install all dependencies.
99
- installDependencies(targetDirectory);
100
- console.log("");
101
- console.log("Done!");
102
- console.log("");
103
- console.log(`Project created at: ${targetDirectory}`);
104
- console.log("");
105
- console.log("Next steps:");
106
- console.log(` cd ${projectName}`);
107
- console.log(" npm run dev");
17
+ if (command === "init") {
18
+ (0, init_1.initializeProject)();
19
+ return;
20
+ }
21
+ if (command === "update") {
22
+ await (0, update_1.updateProject)();
23
+ return;
24
+ }
25
+ (0, create_1.createProject)(command);
108
26
  }
109
27
  catch (error) {
110
28
  console.error("");
@@ -112,13 +30,8 @@ function main() {
112
30
  console.error(error.message);
113
31
  }
114
32
  else {
115
- console.error("Failed to create the project.");
33
+ console.error("Something went wrong.");
116
34
  }
117
- // Do not leave a partially generated project.
118
- node_fs_1.default.rmSync(targetDirectory, {
119
- recursive: true,
120
- force: true,
121
- });
122
35
  process.exit(1);
123
36
  }
124
37
  }
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createProject = createProject;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const files_1 = require("../utils/files");
10
+ const metadata_1 = require("../utils/metadata");
11
+ const packages_1 = require("../utils/packages");
12
+ function updateProjectPackageJson(targetDirectory) {
13
+ const packageJsonPath = node_path_1.default.join(targetDirectory, "package.json");
14
+ const packageJson = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, "utf8"));
15
+ packageJson.name =
16
+ node_path_1.default.basename(targetDirectory);
17
+ const modoockDependencies = (0, packages_1.getLatestModoockDependencies)();
18
+ packageJson.dependencies = {
19
+ ...(packageJson.dependencies ?? {}),
20
+ ...modoockDependencies,
21
+ };
22
+ node_fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
23
+ }
24
+ function createProject(projectName) {
25
+ const targetDirectory = node_path_1.default.resolve(process.cwd(), projectName);
26
+ if (node_fs_1.default.existsSync(targetDirectory)) {
27
+ throw new Error(`Directory "${projectName}" already exists.`);
28
+ }
29
+ const templateDirectory = node_path_1.default.resolve(__dirname, "..", "..", "template");
30
+ console.log(`Creating Modoock project: ${node_path_1.default.basename(targetDirectory)}`);
31
+ try {
32
+ (0, files_1.copyDirectory)(templateDirectory, targetDirectory);
33
+ updateProjectPackageJson(targetDirectory);
34
+ (0, metadata_1.writeModoockMetadata)(targetDirectory);
35
+ (0, packages_1.installDependencies)(targetDirectory);
36
+ console.log("");
37
+ console.log("Done!");
38
+ console.log("");
39
+ console.log(`Project created at: ${targetDirectory}`);
40
+ console.log("");
41
+ console.log("Next steps:");
42
+ console.log(` cd ${projectName}`);
43
+ console.log(" npm run dev");
44
+ }
45
+ catch (error) {
46
+ node_fs_1.default.rmSync(targetDirectory, {
47
+ recursive: true,
48
+ force: true,
49
+ });
50
+ throw error;
51
+ }
52
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initializeProject = initializeProject;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const constants_1 = require("../constants");
10
+ const metadata_1 = require("../utils/metadata");
11
+ function initializeProject() {
12
+ const targetDirectory = process.cwd();
13
+ if (!node_fs_1.default.existsSync(node_path_1.default.join(targetDirectory, "package.json"))) {
14
+ throw new Error("No package.json found in the current directory.");
15
+ }
16
+ const metadataPath = node_path_1.default.join(targetDirectory, constants_1.MODOOCK_DIRECTORY, constants_1.METADATA_FILE);
17
+ if (node_fs_1.default.existsSync(metadataPath)) {
18
+ console.log("This project is already initialized for Modoock updates.");
19
+ return;
20
+ }
21
+ (0, metadata_1.writeModoockMetadata)(targetDirectory);
22
+ console.log("Modoock project initialized successfully.");
23
+ console.log("No project files were modified.");
24
+ }
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.updateProject = updateProject;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const node_readline_1 = __importDefault(require("node:readline"));
10
+ const constants_1 = require("../constants");
11
+ const backup_1 = require("../utils/backup");
12
+ const files_1 = require("../utils/files");
13
+ const metadata_1 = require("../utils/metadata");
14
+ const packages_1 = require("../utils/packages");
15
+ function askQuestion(question) {
16
+ const rl = node_readline_1.default.createInterface({
17
+ input: process.stdin,
18
+ output: process.stdout,
19
+ });
20
+ return new Promise((resolve) => {
21
+ rl.question(question, (answer) => {
22
+ rl.close();
23
+ resolve(answer.trim());
24
+ });
25
+ });
26
+ }
27
+ function getTemplateDirectory() {
28
+ return node_path_1.default.resolve(__dirname, "..", "..", "template");
29
+ }
30
+ function shouldIgnorePath(relativePath) {
31
+ const normalized = relativePath.replace(/\\/g, "/");
32
+ if (normalized ===
33
+ constants_1.MODOOCK_DIRECTORY) {
34
+ return true;
35
+ }
36
+ if (normalized.startsWith(`${constants_1.MODOOCK_DIRECTORY}/`)) {
37
+ return true;
38
+ }
39
+ if (normalized ===
40
+ "package.json") {
41
+ return true;
42
+ }
43
+ if (normalized ===
44
+ "package-lock.json") {
45
+ return true;
46
+ }
47
+ return false;
48
+ }
49
+ function syncNewFilesAndFolders(targetDirectory) {
50
+ const templateDirectory = getTemplateDirectory();
51
+ function syncDirectory(templateDirectoryPath, projectDirectoryPath, relativeDirectory) {
52
+ if (!node_fs_1.default.existsSync(templateDirectoryPath)) {
53
+ return;
54
+ }
55
+ for (const entry of node_fs_1.default.readdirSync(templateDirectoryPath, {
56
+ withFileTypes: true,
57
+ })) {
58
+ const relativePath = relativeDirectory
59
+ ? node_path_1.default.join(relativeDirectory, entry.name)
60
+ : entry.name;
61
+ if (shouldIgnorePath(relativePath)) {
62
+ continue;
63
+ }
64
+ const templatePath = node_path_1.default.join(templateDirectoryPath, entry.name);
65
+ const projectPath = node_path_1.default.join(projectDirectoryPath, entry.name);
66
+ if (entry.isDirectory()) {
67
+ if (!node_fs_1.default.existsSync(projectPath)) {
68
+ node_fs_1.default.cpSync(templatePath, projectPath, {
69
+ recursive: true,
70
+ });
71
+ console.log(`Added folder: ${relativePath}`);
72
+ continue;
73
+ }
74
+ syncDirectory(templatePath, projectPath, relativePath);
75
+ continue;
76
+ }
77
+ if (!node_fs_1.default.existsSync(projectPath)) {
78
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(projectPath), {
79
+ recursive: true,
80
+ });
81
+ node_fs_1.default.copyFileSync(templatePath, projectPath);
82
+ console.log(`Added file: ${relativePath}`);
83
+ }
84
+ }
85
+ }
86
+ syncDirectory(templateDirectory, targetDirectory, "");
87
+ }
88
+ async function updateManagedFiles(targetDirectory, metadata) {
89
+ const templateDirectory = getTemplateDirectory();
90
+ for (const relativePath of constants_1.MANAGED_FILES) {
91
+ const templatePath = node_path_1.default.join(templateDirectory, relativePath);
92
+ const projectPath = node_path_1.default.join(targetDirectory, relativePath);
93
+ if (!node_fs_1.default.existsSync(templatePath)) {
94
+ continue;
95
+ }
96
+ if (!node_fs_1.default.existsSync(projectPath)) {
97
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(projectPath), {
98
+ recursive: true,
99
+ });
100
+ node_fs_1.default.copyFileSync(templatePath, projectPath);
101
+ console.log(`Added: ${relativePath}`);
102
+ continue;
103
+ }
104
+ const originalHash = metadata.managedFiles?.[relativePath];
105
+ const currentHash = (0, files_1.getFileHash)(projectPath);
106
+ if (originalHash &&
107
+ currentHash ===
108
+ originalHash) {
109
+ node_fs_1.default.copyFileSync(templatePath, projectPath);
110
+ console.log(`Updated: ${relativePath}`);
111
+ continue;
112
+ }
113
+ console.log("");
114
+ console.log(`⚠️ Local changes detected: ${relativePath}`);
115
+ console.log("[1] Keep my version");
116
+ console.log("[2] Replace with Modoock version");
117
+ console.log("");
118
+ const answer = await askQuestion("Choose an option (1/2): ");
119
+ if (answer === "1") {
120
+ console.log(`Kept local version: ${relativePath}`);
121
+ continue;
122
+ }
123
+ if (answer === "2") {
124
+ console.log("");
125
+ console.log("⚠️ Your local file will be replaced.");
126
+ console.log("A backup will be created before replacement.");
127
+ const confirmation = await askQuestion("Continue? (y/N): ");
128
+ if (confirmation.toLowerCase() !==
129
+ "y") {
130
+ console.log(`Skipped: ${relativePath}`);
131
+ continue;
132
+ }
133
+ const backupPath = (0, backup_1.createBackup)(targetDirectory, relativePath);
134
+ node_fs_1.default.copyFileSync(templatePath, projectPath);
135
+ console.log(`Backup created: ${node_path_1.default.relative(targetDirectory, backupPath)}`);
136
+ console.log(`Updated: ${relativePath}`);
137
+ continue;
138
+ }
139
+ console.log(`Skipped: ${relativePath}`);
140
+ }
141
+ }
142
+ function updateProjectPackageJson(targetDirectory) {
143
+ const packageJsonPath = node_path_1.default.join(targetDirectory, "package.json");
144
+ const packageJson = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, "utf8"));
145
+ const modoockDependencies = (0, packages_1.getLatestModoockDependencies)();
146
+ packageJson.dependencies = {
147
+ ...(packageJson.dependencies ?? {}),
148
+ ...modoockDependencies,
149
+ };
150
+ node_fs_1.default.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n");
151
+ }
152
+ async function updateProject() {
153
+ const targetDirectory = process.cwd();
154
+ console.log("Updating Modoock project...");
155
+ console.log("");
156
+ const metadata = (0, metadata_1.readModoockMetadata)(targetDirectory);
157
+ console.log(`Current Modoock generator version: ${metadata.generatorVersion}`);
158
+ console.log("");
159
+ // Add files and folders that are new
160
+ // in the Modoock template.
161
+ syncNewFilesAndFolders(targetDirectory);
162
+ // Update explicitly managed files.
163
+ await updateManagedFiles(targetDirectory, metadata);
164
+ console.log("");
165
+ console.log("Updating Modoock dependencies...");
166
+ updateProjectPackageJson(targetDirectory);
167
+ (0, packages_1.installDependencies)(targetDirectory);
168
+ (0, metadata_1.writeModoockMetadata)(targetDirectory);
169
+ console.log("");
170
+ console.log("Modoock update complete.");
171
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.METADATA_FILE = exports.MODOOCK_DIRECTORY = exports.MANAGED_FILES = exports.MODOOCK_PACKAGES = void 0;
4
+ exports.MODOOCK_PACKAGES = [
5
+ "@modoock/components",
6
+ "@modoock/knowledge-base",
7
+ ];
8
+ exports.MANAGED_FILES = [
9
+ "app/globals.css",
10
+ "app/layout.tsx",
11
+ "components/layout/header.tsx",
12
+ "components/layout/app-layout.tsx",
13
+ "components/layout/side-nav.tsx",
14
+ "postcss.config.mjs",
15
+ "next.config.ts",
16
+ ];
17
+ exports.MODOOCK_DIRECTORY = ".modoock";
18
+ exports.METADATA_FILE = "project.json";
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createBackup = createBackup;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
9
+ const constants_1 = require("../constants");
10
+ function createBackup(targetDirectory, relativePath) {
11
+ const timestamp = new Date()
12
+ .toISOString()
13
+ .replace(/[:.]/g, "-");
14
+ const backupDirectory = node_path_1.default.join(targetDirectory, constants_1.MODOOCK_DIRECTORY, "backups", timestamp);
15
+ const sourcePath = node_path_1.default.join(targetDirectory, relativePath);
16
+ const backupPath = node_path_1.default.join(backupDirectory, relativePath);
17
+ node_fs_1.default.mkdirSync(node_path_1.default.dirname(backupPath), {
18
+ recursive: true,
19
+ });
20
+ node_fs_1.default.copyFileSync(sourcePath, backupPath);
21
+ return backupPath;
22
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.copyDirectory = copyDirectory;
7
+ exports.getFileHash = getFileHash;
8
+ const node_crypto_1 = __importDefault(require("node:crypto"));
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const node_path_1 = __importDefault(require("node:path"));
11
+ function copyDirectory(source, destination) {
12
+ node_fs_1.default.mkdirSync(destination, {
13
+ recursive: true,
14
+ });
15
+ for (const entry of node_fs_1.default.readdirSync(source, {
16
+ withFileTypes: true,
17
+ })) {
18
+ const sourcePath = node_path_1.default.join(source, entry.name);
19
+ const destinationPath = node_path_1.default.join(destination, entry.name);
20
+ if (entry.isDirectory()) {
21
+ copyDirectory(sourcePath, destinationPath);
22
+ }
23
+ else {
24
+ node_fs_1.default.copyFileSync(sourcePath, destinationPath);
25
+ }
26
+ }
27
+ }
28
+ function getFileHash(filePath) {
29
+ return node_crypto_1.default
30
+ .createHash("sha256")
31
+ .update(node_fs_1.default.readFileSync(filePath))
32
+ .digest("hex");
33
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPackageVersion = getPackageVersion;
7
+ exports.getManagedFileHashes = getManagedFileHashes;
8
+ exports.writeModoockMetadata = writeModoockMetadata;
9
+ exports.readModoockMetadata = readModoockMetadata;
10
+ const node_fs_1 = __importDefault(require("node:fs"));
11
+ const node_path_1 = __importDefault(require("node:path"));
12
+ const constants_1 = require("../constants");
13
+ const files_1 = require("./files");
14
+ function getPackageVersion() {
15
+ const packageJsonPath = node_path_1.default.resolve(__dirname, "..", "..", "package.json");
16
+ const packageJson = JSON.parse(node_fs_1.default.readFileSync(packageJsonPath, "utf8"));
17
+ return packageJson.version;
18
+ }
19
+ function getManagedFileHashes(targetDirectory) {
20
+ const hashes = {};
21
+ for (const relativePath of constants_1.MANAGED_FILES) {
22
+ const filePath = node_path_1.default.join(targetDirectory, relativePath);
23
+ if (node_fs_1.default.existsSync(filePath)) {
24
+ hashes[relativePath] =
25
+ (0, files_1.getFileHash)(filePath);
26
+ }
27
+ }
28
+ return hashes;
29
+ }
30
+ function writeModoockMetadata(targetDirectory) {
31
+ const modoockDirectory = node_path_1.default.join(targetDirectory, constants_1.MODOOCK_DIRECTORY);
32
+ node_fs_1.default.mkdirSync(modoockDirectory, {
33
+ recursive: true,
34
+ });
35
+ const metadata = {
36
+ generatorVersion: getPackageVersion(),
37
+ managedFiles: getManagedFileHashes(targetDirectory),
38
+ };
39
+ const metadataPath = node_path_1.default.join(modoockDirectory, constants_1.METADATA_FILE);
40
+ node_fs_1.default.writeFileSync(metadataPath, JSON.stringify(metadata, null, 2) + "\n");
41
+ }
42
+ function readModoockMetadata(targetDirectory) {
43
+ const metadataPath = node_path_1.default.join(targetDirectory, constants_1.MODOOCK_DIRECTORY, constants_1.METADATA_FILE);
44
+ if (!node_fs_1.default.existsSync(metadataPath)) {
45
+ throw new Error("This project was not created by create-modoock-app or is missing Modoock metadata.");
46
+ }
47
+ return JSON.parse(node_fs_1.default.readFileSync(metadataPath, "utf8"));
48
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getLatestVersion = getLatestVersion;
4
+ exports.getLatestModoockDependencies = getLatestModoockDependencies;
5
+ exports.installDependencies = installDependencies;
6
+ const node_child_process_1 = require("node:child_process");
7
+ const constants_1 = require("../constants");
8
+ function getLatestVersion(packageName) {
9
+ try {
10
+ const version = (0, node_child_process_1.execSync)(`npm view ${packageName} version`, {
11
+ encoding: "utf8",
12
+ stdio: [
13
+ "ignore",
14
+ "pipe",
15
+ "pipe",
16
+ ],
17
+ }).trim();
18
+ if (!version) {
19
+ throw new Error();
20
+ }
21
+ return version;
22
+ }
23
+ catch {
24
+ throw new Error(`Could not resolve the latest stable version of ${packageName}.`);
25
+ }
26
+ }
27
+ function getLatestModoockDependencies() {
28
+ const dependencies = {};
29
+ for (const packageName of constants_1.MODOOCK_PACKAGES) {
30
+ console.log(`Resolving latest ${packageName}...`);
31
+ const version = getLatestVersion(packageName);
32
+ dependencies[packageName] = version;
33
+ console.log(` ${packageName}@${version}`);
34
+ }
35
+ return dependencies;
36
+ }
37
+ function installDependencies(targetDirectory) {
38
+ console.log("");
39
+ console.log("Installing dependencies...");
40
+ try {
41
+ (0, node_child_process_1.execSync)("npm install", {
42
+ cwd: targetDirectory,
43
+ stdio: "inherit",
44
+ });
45
+ }
46
+ catch {
47
+ throw new Error("Failed to install project dependencies.");
48
+ }
49
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-modoock-app",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Official Modoock project starter and boilerplate generator.",
5
5
  "main": "dist/cli.js",
6
6
  "bin": {
@@ -3,12 +3,10 @@ import fs from "node:fs";
3
3
  import os from "node:os";
4
4
  import path from "node:path";
5
5
 
6
- const CATALOG = "knowledge-base/metadata/catalog.yaml";
7
- const CANONICAL_INDEXES = [
8
- "components/components/ui/index.ts",
9
- "create-modoock-app/template/components/layout/index.ts",
10
- "create-modoock-app/template/components/shared/index.ts",
11
- ];
6
+ const KB_ROOT = "node_modules/@modoock/knowledge-base/knowledge-base";
7
+ const CATALOG = `${KB_ROOT}/metadata/catalog.yaml`;
8
+ const PACKAGE_UI_INDEX =
9
+ "node_modules/@modoock/components/components/ui/index.ts";
12
10
  const allow = { permission: "allow" };
13
11
  const emit = (o) => process.stdout.write(JSON.stringify(o));
14
12
 
@@ -26,23 +24,6 @@ try {
26
24
  )
27
25
  : "";
28
26
 
29
- const monorepoRoot = (() => {
30
- if (
31
- fs.existsSync(path.join(root, "components", "components", "ui")) &&
32
- fs.existsSync(path.join(root, "create-modoock-app", "template", "components"))
33
- ) {
34
- return root;
35
- }
36
- const parent = path.join(root, "..");
37
- if (
38
- fs.existsSync(path.join(parent, "components", "components", "ui")) &&
39
- fs.existsSync(path.join(parent, "create-modoock-app", "template", "components"))
40
- ) {
41
- return parent;
42
- }
43
- return root;
44
- })();
45
-
46
27
  const rel = (file) => {
47
28
  if (!file) return "";
48
29
  const abs = path.resolve(root, String(file));
@@ -50,18 +31,6 @@ try {
50
31
  if (r && !r.startsWith("..") && !path.isAbsolute(r)) {
51
32
  return r.split(path.sep).join("/");
52
33
  }
53
- // Allow stamping canonical sibling sources when workspace is builder/
54
- const fromMono = path.relative(monorepoRoot, abs);
55
- if (
56
- fromMono &&
57
- !fromMono.startsWith("..") &&
58
- !path.isAbsolute(fromMono) &&
59
- CANONICAL_INDEXES.some(
60
- (ip) => fromMono.split(path.sep).join("/") === ip,
61
- )
62
- ) {
63
- return fromMono.split(path.sep).join("/");
64
- }
65
34
  return "";
66
35
  };
67
36
 
@@ -85,18 +54,20 @@ try {
85
54
  };
86
55
 
87
56
  const componentIndexes = () => {
57
+ const indexes = [];
58
+ if (fs.existsSync(path.join(root, PACKAGE_UI_INDEX))) {
59
+ indexes.push(PACKAGE_UI_INDEX);
60
+ }
88
61
  const localDir = path.join(root, "components");
89
62
  if (fs.existsSync(localDir)) {
90
- const local = [];
91
63
  for (const d of fs.readdirSync(localDir, { withFileTypes: true })) {
92
64
  const ip = `components/${d.name}/index.ts`;
93
- if (d.isDirectory() && fs.existsSync(path.join(root, ip))) local.push(ip);
65
+ if (d.isDirectory() && fs.existsSync(path.join(root, ip))) {
66
+ indexes.push(ip);
67
+ }
94
68
  }
95
- if (local.length) return local;
96
69
  }
97
- return CANONICAL_INDEXES.filter((ip) =>
98
- fs.existsSync(path.join(monorepoRoot, ip)),
99
- );
70
+ return indexes;
100
71
  };
101
72
 
102
73
  if (event === "precompact") {
@@ -135,8 +106,12 @@ try {
135
106
  if (!t || t.startsWith("#")) continue;
136
107
  const m = t.match(/^(?:-\s+)?path:\s+(.+)$/);
137
108
  if (m) cur = m[1].trim().replace(/^['"]|['"]$/g, "");
138
- else if (/^load:\s*ui\s*$/.test(t) && cur && fs.existsSync(path.join(root, cur)))
139
- need.push(cur);
109
+ else if (/^load:\s*ui\s*$/.test(t) && cur) {
110
+ const resolved = cur.startsWith("knowledge-base/")
111
+ ? `${KB_ROOT}/${cur.slice("knowledge-base/".length)}`
112
+ : cur;
113
+ if (fs.existsSync(path.join(root, resolved))) need.push(resolved);
114
+ }
140
115
  }
141
116
  }
142
117
  need.push(...componentIndexes());
@@ -6,4 +6,5 @@ alwaysApply: true
6
6
  Follow `AGENTS.md`. If it is already in this conversation, do not re-open it.
7
7
  `.cursor/rules/honey.mdc` is required; if it is already in this conversation, do not re-open it.
8
8
  Do not treat `CLAUDE.md` as a second rulebook.
9
- Then `knowledge-base/metadata/catalog.yaml`.
9
+ Then `node_modules/@modoock/knowledge-base/knowledge-base/metadata/catalog.yaml`.
10
+ UI primitives: `node_modules/@modoock/components/components/ui` (read-only). New components: project `components/` only.
@@ -1,17 +1,26 @@
1
1
  # Development instructions
2
2
 
3
- This file is the canonical router. Product constraints live in `knowledge-base/`. Do not copy them here. Only open the files that match the task.
3
+ This file is the canonical router. Product constraints live in the `@modoock/knowledge-base` package. Do not copy them here. Only open the files that match the task.
4
4
 
5
5
  `CLAUDE.md` imports this file (`@AGENTS.md`) and `.cursor/rules/honey.mdc`. `.cursor/rules/agents.mdc` is a Cursor pointer — do not copy this procedure there. A Next.js footer may be appended here by `next dev`; do not copy it.
6
6
 
7
+ ## Package sources (read-only)
8
+
9
+ | Source | Path on disk | Rule |
10
+ | --- | --- | --- |
11
+ | Knowledge base | `node_modules/@modoock/knowledge-base/knowledge-base/` | Read only. Never edit files under `node_modules/`. |
12
+ | Design System UI | `node_modules/@modoock/components/components/ui/` | Read only. Reuse via `@/components/ui`. Never add or edit UI primitives here. |
13
+
14
+ Alias in this app: `@/components/ui` → package UI. Project-local code lives under `./components/` (layout, shared, and any **new** component the developer approves).
15
+
7
16
  ## Context load
8
17
 
9
18
  | Layer | When | What |
10
19
  | --- | --- | --- |
11
20
  | Always | every turn | this file, `.cursor/rules/honey.mdc` |
12
- | UI files | `app/**` or component sources | every catalog `path` with `load: ui`, then the three component `index.ts` files below |
21
+ | UI files | `app/**` or project `components/**` | every catalog `path` with `load: ui`, then the component `index.ts` files below |
13
22
  | On demand | `description` matches the need | that `path`, then its `open:` |
14
- | After coding | verification | `knowledge-base/validation/` for the change type |
23
+ | After coding | verification | `…/knowledge-base/validation/` for the change type |
15
24
 
16
25
  Do not load the whole knowledge-base. Cursor hook denies writes under `app/` and `components/` until the UI pack (table above) is `Read` this conversation.
17
26
 
@@ -19,6 +28,8 @@ Do not load the whole knowledge-base. Cursor hook denies writes under `app/` and
19
28
 
20
29
  ## Knowledge Base layout
21
30
 
31
+ Resolved under `node_modules/@modoock/knowledge-base/knowledge-base/`:
32
+
22
33
  ```
23
34
  knowledge-base/
24
35
  ├── rules/ # constraints (global, architecture, ui, accessibility, …)
@@ -28,12 +39,21 @@ knowledge-base/
28
39
  └── metadata/ # catalog.yaml — the need → path index
29
40
  ```
30
41
 
42
+ When opening a catalog `path` such as `knowledge-base/rules/…`, read the file at
43
+ `node_modules/@modoock/knowledge-base/<path>`.
44
+
31
45
  ## Which file to open
32
46
 
33
- Open `knowledge-base/metadata/catalog.yaml`. UI edit: every `load: ui` `path`. Then any `description` that matches — exact `path` (no `.mdc` guess). After each catalog `path`, also open that entry's `open:`. What exists (canonical indexes, no `.mdc` required):
34
- - `../components/components/ui/index.ts`
35
- - `../create-modoock-app/template/components/layout/index.ts`
36
- - `../create-modoock-app/template/components/shared/index.ts`
47
+ Open `node_modules/@modoock/knowledge-base/knowledge-base/metadata/catalog.yaml`.
48
+ UI edit: every `load: ui` `path` (prefix with `node_modules/@modoock/knowledge-base/`).
49
+ Then any `description` that matches — exact `path` (no `.mdc` guess). After each catalog `path`, also open that entry's `open:`.
50
+
51
+ What exists (canonical indexes):
52
+
53
+ - **Package UI (read-only):** `node_modules/@modoock/components/components/ui/index.ts`
54
+ - **Project layout:** `components/layout/index.ts`
55
+ - **Project shared:** `components/shared/index.ts`
56
+ - **Project UI (local only):** `components/ui/index.ts` — only for new app-level UI after human validation; do **not** duplicate package primitives here
37
57
 
38
58
  If no file covers the need, follow **New rules**. Missing `.mdc` for an existing export is not a gap.
39
59
 
@@ -49,7 +69,7 @@ Break the request down first. All six are required. Do not write this breakdown
49
69
  6. **Comment** — only if a part is uncovered: ask per **Mandatory human validation**, then wait.
50
70
 
51
71
  - Inspect the existing code. Reproduce a failure before fixing it. Change one thing at a time, then verify.
52
- - Reuse: `knowledge-base/design-system/components.mdc`. Composition: `knowledge-base/rules/architecture/composition.mdc`. APIs: the three `index.ts` above.
72
+ - Reuse: package `components.mdc` + package UI `index.ts`. Composition: `knowledge-base/rules/architecture/composition.mdc`. Project APIs: `components/layout/index.ts`, `components/shared/index.ts`.
53
73
  - Apply **Mandatory human validation**.
54
74
 
55
75
  ## Mandatory human validation
@@ -57,35 +77,35 @@ Break the request down first. All six are required. Do not write this breakdown
57
77
  Compose with existing primitives (group, order, space, hierarchy, empty/loading/error). Do not ask for that.
58
78
 
59
79
  Ask and wait only for:
60
- - a new public component in `../components/components/ui` | `../create-modoock-app/template/components/layout` | `../create-modoock-app/template/components/shared`
80
+ - a new public component in the **project** `components/ui` | `components/layout` | `components/shared` (never in `node_modules/@modoock/components`)
61
81
  - a new token or global variable
62
82
  - an interaction not named in the catalog / `patterns/`
63
83
  - an ambiguous product requirement (purpose, data, action)
64
84
 
65
- Yes → implement. No → leave out. Do not hide a Design System piece as page-local to skip the ask.
85
+ Yes → implement under `./components/…`. No → leave out. Do not hide a Design System piece as page-local to skip the ask. Do not patch `@modoock/components` or `@modoock/knowledge-base`.
66
86
 
67
87
  New component block:
68
88
  - **What:** Name
69
- - **Where:** path above
70
- - **Why:** which `index.ts` exports do not fit
89
+ - **Where:** `components/ui` | `components/layout` | `components/shared` (project root only)
90
+ - **Why:** which package / project `index.ts` exports do not fit
71
91
  - **Reuse:** one sentence
72
92
 
73
93
  ## New rules
74
94
 
75
95
  When a recurring case is not covered:
76
96
 
77
- - Propose a new rule, why it is recurring, and where it belongs (`knowledge-base/` or `components/`).
78
- - Do not add or modify a rule until the developer says yes. Then add it.
97
+ - Propose a new rule, why it is recurring, and where it would belong in the knowledge-base package (do not edit `node_modules`).
98
+ - Do not add or modify a rule until the developer says yes. Then add it only if the developer provides a writable knowledge-base location; otherwise stop.
79
99
 
80
100
  ## Verification
81
101
 
82
- Layers (do not mix): `npm run lint` = ESLint. `npm run typecheck` = TypeScript, including JSX props on the public type. `npm run sg:scan` = structural facts the scanner can prove — keep it strict and dumb. `knowledge-base/validation/` = Design System / UX / architecture. The agent = context and judgment.
102
+ Layers (do not mix): `npm run lint` = ESLint. `npm run typecheck` = TypeScript, including JSX props on the public type. `npm run sg:scan` = structural facts the scanner can prove — keep it strict and dumb. Package `knowledge-base/validation/` = Design System / UX / architecture. The agent = context and judgment.
83
103
 
84
104
  After a modification:
85
105
 
86
- - Check the change against `knowledge-base/validation/` for the files that match. For a read-only pass on the diff, use `.cursor/agents/code-reviewer.md`.
106
+ - Check the change against package `knowledge-base/validation/` for the files that match. For a read-only pass on the diff, use `.cursor/agents/code-reviewer.md`.
87
107
  - Check that existing features are not unnecessarily affected.
88
- - If a new component has been created, export it from the folder `index.ts` at the canonical path (`../components/components/ui/`, `../create-modoock-app/template/components/layout/`, or `../create-modoock-app/template/components/shared/`).
108
+ - If a new component has been created in the **project**, export it from that folder's `index.ts` (`components/ui/`, `components/layout/`, or `components/shared/`). Never export into the package under `node_modules`.
89
109
  - Run `npm run lint`, `npm run typecheck` and `npm run sg:scan` and fix any **error** before finishing. `typecheck` proves JSX props exist on the component type. Do not apply catalog auto-fixes (`ast-grep scan -U`) and do not rewrite existing app JSX to silence catalog warnings.
90
110
  - Report any problems or hypotheses that require a decision from the developer.
91
111
 
@@ -1,4 +1,5 @@
1
1
  @import "tailwindcss";
2
+ @source "../node_modules/@modoock/components/dist";
2
3
 
3
4
  /* ================================
4
5
  DESIGN TOKENS
@@ -25,10 +25,10 @@
25
25
  "baseUrl": ".",
26
26
  "paths": {
27
27
  "@/components/ui": [
28
- "../../components/components/ui"
28
+ "./node_modules/@modoock/components/components/ui"
29
29
  ],
30
30
  "@/components/ui/*": [
31
- "../../components/components/ui/*"
31
+ "./node_modules/@modoock/components/components/ui/*"
32
32
  ],
33
33
  "react": [
34
34
  "./node_modules/@types/react"