@coherent.js/cli 1.0.0-beta.2 → 1.0.0-beta.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/dist/index.cjs +2101 -11612
- package/dist/index.js +101 -75
- package/package.json +1 -4
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/index.js
|
|
2
2
|
import { Command as Command6 } from "commander";
|
|
3
|
-
import { readFileSync as
|
|
4
|
-
import { fileURLToPath as
|
|
5
|
-
import { dirname as
|
|
3
|
+
import { readFileSync as readFileSync7 } from "fs";
|
|
4
|
+
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
5
|
+
import { dirname as dirname3, join as join8 } from "path";
|
|
6
6
|
import picocolors6 from "picocolors";
|
|
7
7
|
|
|
8
8
|
// src/commands/create.js
|
|
@@ -15,10 +15,33 @@ import { resolve as resolve2 } from "path";
|
|
|
15
15
|
|
|
16
16
|
// src/generators/project-scaffold.js
|
|
17
17
|
import { writeFileSync, mkdirSync } from "node:fs";
|
|
18
|
-
import { join, dirname } from "node:path";
|
|
18
|
+
import { join as join2, dirname as dirname2 } from "node:path";
|
|
19
19
|
import { execSync } from "node:child_process";
|
|
20
20
|
|
|
21
|
+
// src/utils/version.js
|
|
22
|
+
import { readFileSync } from "fs";
|
|
23
|
+
import { join, dirname } from "path";
|
|
24
|
+
import { fileURLToPath } from "url";
|
|
25
|
+
var cachedVersion = null;
|
|
26
|
+
function getCLIVersion() {
|
|
27
|
+
if (cachedVersion) {
|
|
28
|
+
return cachedVersion;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const __filename2 = fileURLToPath(import.meta.url);
|
|
32
|
+
const __dirname2 = dirname(__filename2);
|
|
33
|
+
const packagePath = join(__dirname2, "..", "..", "package.json");
|
|
34
|
+
const packageJson = JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
35
|
+
cachedVersion = packageJson.version;
|
|
36
|
+
return cachedVersion;
|
|
37
|
+
} catch {
|
|
38
|
+
cachedVersion = process.env.COHERENT_CLI_VERSION || "1.0.0-beta.3";
|
|
39
|
+
return cachedVersion;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
21
43
|
// src/generators/runtime-scaffold.js
|
|
44
|
+
var cliVersion = getCLIVersion();
|
|
22
45
|
function generateBuiltInServer(options = {}) {
|
|
23
46
|
const { port = 3e3, hasApi = false, hasDatabase = false } = options;
|
|
24
47
|
const imports = [
|
|
@@ -239,20 +262,20 @@ function getRuntimeDependencies(runtime) {
|
|
|
239
262
|
const deps = {
|
|
240
263
|
"built-in": {},
|
|
241
264
|
express: {
|
|
242
|
-
express: "^4.
|
|
243
|
-
"@coherent.js/express":
|
|
265
|
+
express: "^4.19.2",
|
|
266
|
+
"@coherent.js/express": `^${cliVersion}`
|
|
244
267
|
},
|
|
245
268
|
fastify: {
|
|
246
269
|
fastify: "^4.28.1",
|
|
247
270
|
"@fastify/static": "^7.0.4",
|
|
248
|
-
"@coherent.js/fastify":
|
|
271
|
+
"@coherent.js/fastify": `^${cliVersion}`
|
|
249
272
|
},
|
|
250
273
|
koa: {
|
|
251
274
|
koa: "^2.15.3",
|
|
252
275
|
"@koa/router": "^13.0.1",
|
|
253
276
|
"koa-body": "^6.0.1",
|
|
254
277
|
"koa-static": "^5.0.0",
|
|
255
|
-
"@coherent.js/koa":
|
|
278
|
+
"@coherent.js/koa": `^${cliVersion}`
|
|
256
279
|
}
|
|
257
280
|
};
|
|
258
281
|
return deps[runtime] || {};
|
|
@@ -273,6 +296,7 @@ function generateServerFile(runtime, options = {}) {
|
|
|
273
296
|
}
|
|
274
297
|
|
|
275
298
|
// src/generators/database-scaffold.js
|
|
299
|
+
var cliVersion2 = getCLIVersion();
|
|
276
300
|
function generateDatabaseConfig(dbType) {
|
|
277
301
|
const configs = {
|
|
278
302
|
postgres: `
|
|
@@ -738,19 +762,19 @@ function getDatabaseDependencies(dbType) {
|
|
|
738
762
|
const deps = {
|
|
739
763
|
postgres: {
|
|
740
764
|
pg: "^8.12.0",
|
|
741
|
-
"@coherent.js/database":
|
|
765
|
+
"@coherent.js/database": `^${cliVersion2}`
|
|
742
766
|
},
|
|
743
767
|
mysql: {
|
|
744
768
|
"mysql2": "^3.11.0",
|
|
745
|
-
"@coherent.js/database":
|
|
769
|
+
"@coherent.js/database": `^${cliVersion2}`
|
|
746
770
|
},
|
|
747
771
|
sqlite: {
|
|
748
772
|
"better-sqlite3": "^11.3.0",
|
|
749
|
-
"@coherent.js/database":
|
|
773
|
+
"@coherent.js/database": `^${cliVersion2}`
|
|
750
774
|
},
|
|
751
775
|
mongodb: {
|
|
752
776
|
mongodb: "^6.9.0",
|
|
753
|
-
"@coherent.js/database":
|
|
777
|
+
"@coherent.js/database": `^${cliVersion2}`
|
|
754
778
|
}
|
|
755
779
|
};
|
|
756
780
|
return deps[dbType] || {};
|
|
@@ -1448,6 +1472,7 @@ function generateAuthScaffolding(authType, runtime) {
|
|
|
1448
1472
|
}
|
|
1449
1473
|
|
|
1450
1474
|
// src/generators/package-scaffold.js
|
|
1475
|
+
var cliVersion3 = getCLIVersion();
|
|
1451
1476
|
function generateApiScaffolding() {
|
|
1452
1477
|
const routes = `
|
|
1453
1478
|
import { createRouter } from '@coherent.js/api';
|
|
@@ -1484,7 +1509,7 @@ export default router;
|
|
|
1484
1509
|
return {
|
|
1485
1510
|
"src/api/routes.js": routes,
|
|
1486
1511
|
dependencies: {
|
|
1487
|
-
"@coherent.js/api":
|
|
1512
|
+
"@coherent.js/api": `^${cliVersion3}`
|
|
1488
1513
|
}
|
|
1489
1514
|
};
|
|
1490
1515
|
}
|
|
@@ -1573,7 +1598,7 @@ if (typeof window !== 'undefined') {
|
|
|
1573
1598
|
"public/js/hydration.js": hydration,
|
|
1574
1599
|
"src/components/InteractiveCounter.js": interactiveExample,
|
|
1575
1600
|
dependencies: {
|
|
1576
|
-
"@coherent.js/client":
|
|
1601
|
+
"@coherent.js/client": `^${cliVersion3}`
|
|
1577
1602
|
}
|
|
1578
1603
|
};
|
|
1579
1604
|
}
|
|
@@ -1634,7 +1659,7 @@ export const i18n = createI18n({
|
|
|
1634
1659
|
"src/i18n/locales/fr.json": frLocale,
|
|
1635
1660
|
"src/i18n/locales/es.json": esLocale,
|
|
1636
1661
|
dependencies: {
|
|
1637
|
-
"@coherent.js/i18n":
|
|
1662
|
+
"@coherent.js/i18n": `^${cliVersion3}`
|
|
1638
1663
|
}
|
|
1639
1664
|
};
|
|
1640
1665
|
}
|
|
@@ -1692,7 +1717,7 @@ export function ContactForm(props = {}) {
|
|
|
1692
1717
|
return {
|
|
1693
1718
|
"src/components/ContactForm.js": exampleForm,
|
|
1694
1719
|
dependencies: {
|
|
1695
|
-
"@coherent.js/forms":
|
|
1720
|
+
"@coherent.js/forms": `^${cliVersion3}`
|
|
1696
1721
|
}
|
|
1697
1722
|
};
|
|
1698
1723
|
}
|
|
@@ -1720,7 +1745,7 @@ export function initDevtools(app) {
|
|
|
1720
1745
|
return {
|
|
1721
1746
|
"src/utils/devtools.js": config,
|
|
1722
1747
|
dependencies: {
|
|
1723
|
-
"@coherent.js/devtools":
|
|
1748
|
+
"@coherent.js/devtools": `^${cliVersion3}`
|
|
1724
1749
|
}
|
|
1725
1750
|
};
|
|
1726
1751
|
}
|
|
@@ -1769,7 +1794,7 @@ export function getSitemap() {
|
|
|
1769
1794
|
return {
|
|
1770
1795
|
"src/utils/seo.js": metaHelper,
|
|
1771
1796
|
dependencies: {
|
|
1772
|
-
"@coherent.js/seo":
|
|
1797
|
+
"@coherent.js/seo": `^${cliVersion3}`
|
|
1773
1798
|
}
|
|
1774
1799
|
};
|
|
1775
1800
|
}
|
|
@@ -1837,7 +1862,7 @@ describe('HomePage', () => {
|
|
|
1837
1862
|
"tests/helpers/testing.js": testHelper,
|
|
1838
1863
|
"tests/components/HomePage.test.js": exampleTest,
|
|
1839
1864
|
dependencies: {
|
|
1840
|
-
"@coherent.js/testing":
|
|
1865
|
+
"@coherent.js/testing": `^${cliVersion3}`
|
|
1841
1866
|
}
|
|
1842
1867
|
};
|
|
1843
1868
|
}
|
|
@@ -1972,6 +1997,7 @@ function getTypeScriptDependencies() {
|
|
|
1972
1997
|
}
|
|
1973
1998
|
|
|
1974
1999
|
// src/generators/project-scaffold.js
|
|
2000
|
+
var cliVersion4 = getCLIVersion();
|
|
1975
2001
|
async function scaffoldProject(projectPath, options) {
|
|
1976
2002
|
const {
|
|
1977
2003
|
name,
|
|
@@ -2012,16 +2038,16 @@ async function scaffoldProject(projectPath, options) {
|
|
|
2012
2038
|
dirs.push("src/i18n", "src/i18n/locales");
|
|
2013
2039
|
}
|
|
2014
2040
|
dirs.forEach((dir) => {
|
|
2015
|
-
mkdirSync(
|
|
2041
|
+
mkdirSync(join2(projectPath, dir), { recursive: true });
|
|
2016
2042
|
});
|
|
2017
2043
|
const packageJson = generatePackageJson(name, { template, runtime, database, auth, packages, language, packageManager });
|
|
2018
|
-
writeFileSync(
|
|
2044
|
+
writeFileSync(join2(projectPath, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
2019
2045
|
if (isTypeScript) {
|
|
2020
2046
|
const tsConfig = generateTsConfig();
|
|
2021
|
-
writeFileSync(
|
|
2047
|
+
writeFileSync(join2(projectPath, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
|
|
2022
2048
|
} else {
|
|
2023
2049
|
const jsConfig = generateJsConfig();
|
|
2024
|
-
writeFileSync(
|
|
2050
|
+
writeFileSync(join2(projectPath, "jsconfig.json"), JSON.stringify(jsConfig, null, 2));
|
|
2025
2051
|
}
|
|
2026
2052
|
const serverContent = generateServerFile(runtime, {
|
|
2027
2053
|
port: 3e3,
|
|
@@ -2029,30 +2055,30 @@ async function scaffoldProject(projectPath, options) {
|
|
|
2029
2055
|
hasDatabase: !!database,
|
|
2030
2056
|
hasAuth: !!auth
|
|
2031
2057
|
});
|
|
2032
|
-
writeFileSync(
|
|
2058
|
+
writeFileSync(join2(projectPath, `src/index${fileExtension}`), serverContent);
|
|
2033
2059
|
await generateHomePageComponent(projectPath, name, isTypeScript, fileExtension);
|
|
2034
2060
|
if (database) {
|
|
2035
2061
|
const dbScaffolding = generateDatabaseScaffolding(database);
|
|
2036
|
-
writeFileSync(
|
|
2037
|
-
writeFileSync(
|
|
2038
|
-
writeFileSync(
|
|
2062
|
+
writeFileSync(join2(projectPath, "src/db/config.js"), dbScaffolding.config);
|
|
2063
|
+
writeFileSync(join2(projectPath, "src/db/index.js"), dbScaffolding.init);
|
|
2064
|
+
writeFileSync(join2(projectPath, "src/db/models/User.js"), dbScaffolding.model);
|
|
2039
2065
|
const existingEnv = "";
|
|
2040
|
-
writeFileSync(
|
|
2066
|
+
writeFileSync(join2(projectPath, ".env.example"), existingEnv + dbScaffolding.env);
|
|
2041
2067
|
}
|
|
2042
2068
|
if (auth) {
|
|
2043
2069
|
const authScaffolding = generateAuthScaffolding(auth, runtime);
|
|
2044
2070
|
const authDir = runtime === "fastify" ? "plugins" : "middleware";
|
|
2045
|
-
writeFileSync(
|
|
2046
|
-
writeFileSync(
|
|
2047
|
-
const envPath =
|
|
2071
|
+
writeFileSync(join2(projectPath, `src/${authDir}/auth.js`), authScaffolding.middleware);
|
|
2072
|
+
writeFileSync(join2(projectPath, "src/api/auth.js"), authScaffolding.routes);
|
|
2073
|
+
const envPath = join2(projectPath, ".env.example");
|
|
2048
2074
|
const existingEnv = "";
|
|
2049
2075
|
writeFileSync(envPath, existingEnv + authScaffolding.env);
|
|
2050
2076
|
}
|
|
2051
2077
|
if (packages.length > 0) {
|
|
2052
2078
|
const { files } = generatePackageScaffolding(packages);
|
|
2053
2079
|
Object.entries(files).forEach(([filePath, content]) => {
|
|
2054
|
-
const fullPath =
|
|
2055
|
-
mkdirSync(
|
|
2080
|
+
const fullPath = join2(projectPath, filePath);
|
|
2081
|
+
mkdirSync(dirname2(fullPath), { recursive: true });
|
|
2056
2082
|
writeFileSync(fullPath, content);
|
|
2057
2083
|
});
|
|
2058
2084
|
}
|
|
@@ -2107,10 +2133,10 @@ function generatePackageJson(name, options) {
|
|
|
2107
2133
|
test: "node --test tests/*.test.js"
|
|
2108
2134
|
},
|
|
2109
2135
|
dependencies: {
|
|
2110
|
-
"@coherent.js/core":
|
|
2136
|
+
"@coherent.js/core": `^${cliVersion4}`
|
|
2111
2137
|
},
|
|
2112
2138
|
devDependencies: {
|
|
2113
|
-
"@coherent.js/cli":
|
|
2139
|
+
"@coherent.js/cli": `^${cliVersion4}`
|
|
2114
2140
|
}
|
|
2115
2141
|
};
|
|
2116
2142
|
if (isTypeScript) {
|
|
@@ -2222,7 +2248,7 @@ export function HomePage(props = {}) {
|
|
|
2222
2248
|
};
|
|
2223
2249
|
}
|
|
2224
2250
|
`;
|
|
2225
|
-
writeFileSync(
|
|
2251
|
+
writeFileSync(join2(projectPath, `src/components/HomePage${fileExtension}`), homePage);
|
|
2226
2252
|
const buttonComponent = isTypeScript ? `/**
|
|
2227
2253
|
* Button Component
|
|
2228
2254
|
*/
|
|
@@ -2258,7 +2284,7 @@ export function Button(props = {}) {
|
|
|
2258
2284
|
};
|
|
2259
2285
|
}
|
|
2260
2286
|
`;
|
|
2261
|
-
writeFileSync(
|
|
2287
|
+
writeFileSync(join2(projectPath, `src/components/Button${fileExtension}`), buttonComponent);
|
|
2262
2288
|
}
|
|
2263
2289
|
function generateCommonFiles(projectPath, name) {
|
|
2264
2290
|
const readme = `# ${name}
|
|
@@ -2303,7 +2329,7 @@ tests/ # Test files
|
|
|
2303
2329
|
|
|
2304
2330
|
MIT
|
|
2305
2331
|
`;
|
|
2306
|
-
writeFileSync(
|
|
2332
|
+
writeFileSync(join2(projectPath, "README.md"), readme);
|
|
2307
2333
|
const gitignore = `# Dependencies
|
|
2308
2334
|
node_modules/
|
|
2309
2335
|
npm-debug.log*
|
|
@@ -2360,7 +2386,7 @@ logs
|
|
|
2360
2386
|
# Optional REPL history
|
|
2361
2387
|
.node_repl_history
|
|
2362
2388
|
`;
|
|
2363
|
-
writeFileSync(
|
|
2389
|
+
writeFileSync(join2(projectPath, ".gitignore"), gitignore);
|
|
2364
2390
|
const testFile = `import { test } from 'node:test';
|
|
2365
2391
|
import assert from 'node:assert';
|
|
2366
2392
|
import { render } from '@coherent.js/core';
|
|
@@ -2376,7 +2402,7 @@ test('renders basic component', () => {
|
|
|
2376
2402
|
assert(html.includes('Hello, World!'));
|
|
2377
2403
|
});
|
|
2378
2404
|
`;
|
|
2379
|
-
writeFileSync(
|
|
2405
|
+
writeFileSync(join2(projectPath, "tests/basic.test.js"), testFile);
|
|
2380
2406
|
}
|
|
2381
2407
|
|
|
2382
2408
|
// src/utils/validation.js
|
|
@@ -2699,29 +2725,29 @@ import picocolors2 from "picocolors";
|
|
|
2699
2725
|
|
|
2700
2726
|
// src/generators/component-generator.js
|
|
2701
2727
|
import { writeFileSync as writeFileSync2, existsSync as existsSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
2702
|
-
import { join as
|
|
2728
|
+
import { join as join3 } from "path";
|
|
2703
2729
|
async function generateComponent(name, options = {}) {
|
|
2704
2730
|
const { path: path2 = "src/components", template = "basic", skipTest = false, skipStory = false } = options;
|
|
2705
2731
|
const componentName = toPascalCase(name);
|
|
2706
2732
|
const fileName = componentName;
|
|
2707
|
-
const outputDir =
|
|
2733
|
+
const outputDir = join3(process.cwd(), path2);
|
|
2708
2734
|
if (!existsSync3(outputDir)) {
|
|
2709
2735
|
mkdirSync3(outputDir, { recursive: true });
|
|
2710
2736
|
}
|
|
2711
2737
|
const files = [];
|
|
2712
2738
|
const nextSteps = [];
|
|
2713
|
-
const componentPath =
|
|
2739
|
+
const componentPath = join3(outputDir, `${fileName}.js`);
|
|
2714
2740
|
const componentContent = generateComponentContent(componentName, template);
|
|
2715
2741
|
writeFileSync2(componentPath, componentContent);
|
|
2716
2742
|
files.push(componentPath);
|
|
2717
2743
|
if (!skipTest) {
|
|
2718
|
-
const testPath =
|
|
2744
|
+
const testPath = join3(outputDir, `${fileName}.test.js`);
|
|
2719
2745
|
const testContent = generateTestContent(componentName);
|
|
2720
2746
|
writeFileSync2(testPath, testContent);
|
|
2721
2747
|
files.push(testPath);
|
|
2722
2748
|
}
|
|
2723
2749
|
if (!skipStory) {
|
|
2724
|
-
const storyPath =
|
|
2750
|
+
const storyPath = join3(outputDir, `${fileName}.stories.js`);
|
|
2725
2751
|
const storyContent = generateStoryContent(componentName);
|
|
2726
2752
|
writeFileSync2(storyPath, storyContent);
|
|
2727
2753
|
files.push(storyPath);
|
|
@@ -3085,23 +3111,23 @@ function toPascalCase(str) {
|
|
|
3085
3111
|
|
|
3086
3112
|
// src/generators/page-generator.js
|
|
3087
3113
|
import { writeFileSync as writeFileSync3, existsSync as existsSync4, mkdirSync as mkdirSync4 } from "fs";
|
|
3088
|
-
import { join as
|
|
3114
|
+
import { join as join4 } from "path";
|
|
3089
3115
|
async function generatePage(name, options = {}) {
|
|
3090
3116
|
const { path: path2 = "src/pages", template = "basic", skipTest = false } = options;
|
|
3091
3117
|
const pageName = toPascalCase2(name);
|
|
3092
3118
|
const fileName = pageName;
|
|
3093
|
-
const outputDir =
|
|
3119
|
+
const outputDir = join4(process.cwd(), path2);
|
|
3094
3120
|
if (!existsSync4(outputDir)) {
|
|
3095
3121
|
mkdirSync4(outputDir, { recursive: true });
|
|
3096
3122
|
}
|
|
3097
3123
|
const files = [];
|
|
3098
3124
|
const nextSteps = [];
|
|
3099
|
-
const pagePath =
|
|
3125
|
+
const pagePath = join4(outputDir, `${fileName}.js`);
|
|
3100
3126
|
const pageContent = generatePageContent(pageName, template);
|
|
3101
3127
|
writeFileSync3(pagePath, pageContent);
|
|
3102
3128
|
files.push(pagePath);
|
|
3103
3129
|
if (!skipTest) {
|
|
3104
|
-
const testPath =
|
|
3130
|
+
const testPath = join4(outputDir, `${fileName}.test.js`);
|
|
3105
3131
|
const testContent = generateTestContent2(pageName);
|
|
3106
3132
|
writeFileSync3(testPath, testContent);
|
|
3107
3133
|
files.push(testPath);
|
|
@@ -3647,23 +3673,23 @@ function toPascalCase2(str) {
|
|
|
3647
3673
|
|
|
3648
3674
|
// src/generators/api-generator.js
|
|
3649
3675
|
import { writeFileSync as writeFileSync4, existsSync as existsSync5, mkdirSync as mkdirSync5 } from "fs";
|
|
3650
|
-
import { join as
|
|
3676
|
+
import { join as join5 } from "path";
|
|
3651
3677
|
async function generateAPI(name, options = {}) {
|
|
3652
3678
|
const { path: path2 = "src/api", template = "rest", skipTest = false } = options;
|
|
3653
3679
|
const apiName = toKebabCase(name);
|
|
3654
3680
|
const fileName = apiName;
|
|
3655
|
-
const outputDir =
|
|
3681
|
+
const outputDir = join5(process.cwd(), path2);
|
|
3656
3682
|
if (!existsSync5(outputDir)) {
|
|
3657
3683
|
mkdirSync5(outputDir, { recursive: true });
|
|
3658
3684
|
}
|
|
3659
3685
|
const files = [];
|
|
3660
3686
|
const nextSteps = [];
|
|
3661
|
-
const apiPath =
|
|
3687
|
+
const apiPath = join5(outputDir, `${fileName}.js`);
|
|
3662
3688
|
const apiContent = generateAPIContent(apiName, name, template);
|
|
3663
3689
|
writeFileSync4(apiPath, apiContent);
|
|
3664
3690
|
files.push(apiPath);
|
|
3665
3691
|
if (!skipTest) {
|
|
3666
|
-
const testPath =
|
|
3692
|
+
const testPath = join5(outputDir, `${fileName}.test.js`);
|
|
3667
3693
|
const testContent = generateTestContent3(apiName, name);
|
|
3668
3694
|
writeFileSync4(testPath, testContent);
|
|
3669
3695
|
files.push(testPath);
|
|
@@ -4290,19 +4316,19 @@ import { Command as Command3 } from "commander";
|
|
|
4290
4316
|
import ora3 from "ora";
|
|
4291
4317
|
import picocolors3 from "picocolors";
|
|
4292
4318
|
import { execSync as execSync2 } from "child_process";
|
|
4293
|
-
import { existsSync as existsSync6, readFileSync } from "fs";
|
|
4294
|
-
import { join as
|
|
4319
|
+
import { existsSync as existsSync6, readFileSync as readFileSync2 } from "fs";
|
|
4320
|
+
import { join as join6 } from "path";
|
|
4295
4321
|
var buildCommand = new Command3("build").description("Build the project for production").option("-w, --watch", "watch for changes").option("--analyze", "analyze bundle size").option("--no-minify", "disable minification").option("--no-optimize", "disable optimizations").action(async (options) => {
|
|
4296
4322
|
console.log(picocolors3.cyan("\u{1F3D7}\uFE0F Building Coherent.js project..."));
|
|
4297
4323
|
console.log();
|
|
4298
|
-
const packageJsonPath =
|
|
4324
|
+
const packageJsonPath = join6(process.cwd(), "package.json");
|
|
4299
4325
|
if (!existsSync6(packageJsonPath)) {
|
|
4300
4326
|
console.error(picocolors3.red("\u274C No package.json found. Are you in a project directory?"));
|
|
4301
4327
|
process.exit(1);
|
|
4302
4328
|
}
|
|
4303
4329
|
let packageJson;
|
|
4304
4330
|
try {
|
|
4305
|
-
packageJson = JSON.parse(
|
|
4331
|
+
packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
4306
4332
|
} catch {
|
|
4307
4333
|
console.error(picocolors3.red("\u274C Failed to read package.json"));
|
|
4308
4334
|
process.exit(1);
|
|
@@ -4397,19 +4423,19 @@ import { Command as Command4 } from "commander";
|
|
|
4397
4423
|
import ora4 from "ora";
|
|
4398
4424
|
import picocolors4 from "picocolors";
|
|
4399
4425
|
import { spawn } from "child_process";
|
|
4400
|
-
import { existsSync as existsSync7, readFileSync as
|
|
4401
|
-
import { join as
|
|
4426
|
+
import { existsSync as existsSync7, readFileSync as readFileSync3 } from "fs";
|
|
4427
|
+
import { join as join7 } from "path";
|
|
4402
4428
|
var devCommand = new Command4("dev").description("Start development server with hot reload").option("-p, --port <port>", "port number", "3000").option("-h, --host <host>", "host address", "localhost").option("--open", "open browser automatically").option("--no-hmr", "disable hot module replacement").action(async (options) => {
|
|
4403
4429
|
console.log(picocolors4.cyan("\u{1F680} Starting Coherent.js development server..."));
|
|
4404
4430
|
console.log();
|
|
4405
|
-
const packageJsonPath =
|
|
4431
|
+
const packageJsonPath = join7(process.cwd(), "package.json");
|
|
4406
4432
|
if (!existsSync7(packageJsonPath)) {
|
|
4407
4433
|
console.error(picocolors4.red("\u274C No package.json found. Are you in a project directory?"));
|
|
4408
4434
|
process.exit(1);
|
|
4409
4435
|
}
|
|
4410
4436
|
let packageJson;
|
|
4411
4437
|
try {
|
|
4412
|
-
packageJson = JSON.parse(
|
|
4438
|
+
packageJson = JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
|
|
4413
4439
|
} catch {
|
|
4414
4440
|
console.error(picocolors4.red("\u274C Failed to read package.json"));
|
|
4415
4441
|
process.exit(1);
|
|
@@ -4509,11 +4535,11 @@ import { Command as Command5 } from "commander";
|
|
|
4509
4535
|
import prompts3 from "prompts";
|
|
4510
4536
|
import ora5 from "ora";
|
|
4511
4537
|
import picocolors5 from "picocolors";
|
|
4512
|
-
import { existsSync as existsSync10, readFileSync as
|
|
4538
|
+
import { existsSync as existsSync10, readFileSync as readFileSync6 } from "fs";
|
|
4513
4539
|
import { resolve as resolve5 } from "path";
|
|
4514
4540
|
|
|
4515
4541
|
// src/analyzers/component-analyzer.js
|
|
4516
|
-
import { readFileSync as
|
|
4542
|
+
import { readFileSync as readFileSync4, existsSync as existsSync8 } from "fs";
|
|
4517
4543
|
import { resolve as resolve3 } from "path";
|
|
4518
4544
|
|
|
4519
4545
|
// ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
|
|
@@ -6055,7 +6081,7 @@ minimatch.escape = escape;
|
|
|
6055
6081
|
minimatch.unescape = unescape;
|
|
6056
6082
|
|
|
6057
6083
|
// ../../node_modules/.pnpm/glob@11.0.3/node_modules/glob/dist/esm/glob.js
|
|
6058
|
-
import { fileURLToPath as
|
|
6084
|
+
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
6059
6085
|
|
|
6060
6086
|
// ../../node_modules/.pnpm/lru-cache@11.2.1/node_modules/lru-cache/dist/esm/index.js
|
|
6061
6087
|
var defaultPerf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
|
|
@@ -7459,7 +7485,7 @@ var LRUCache = class _LRUCache {
|
|
|
7459
7485
|
|
|
7460
7486
|
// ../../node_modules/.pnpm/path-scurry@2.0.0/node_modules/path-scurry/dist/esm/index.js
|
|
7461
7487
|
import { posix, win32 } from "node:path";
|
|
7462
|
-
import { fileURLToPath } from "node:url";
|
|
7488
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
7463
7489
|
import { lstatSync, readdir as readdirCB, readdirSync, readlinkSync, realpathSync as rps } from "fs";
|
|
7464
7490
|
import * as actualFS from "node:fs";
|
|
7465
7491
|
import { lstat, readdir, readlink, realpath } from "node:fs/promises";
|
|
@@ -9464,7 +9490,7 @@ var PathScurryBase = class {
|
|
|
9464
9490
|
constructor(cwd = process.cwd(), pathImpl, sep2, { nocase, childrenCacheSize = 16 * 1024, fs = defaultFS } = {}) {
|
|
9465
9491
|
this.#fs = fsFromOption(fs);
|
|
9466
9492
|
if (cwd instanceof URL || cwd.startsWith("file://")) {
|
|
9467
|
-
cwd =
|
|
9493
|
+
cwd = fileURLToPath2(cwd);
|
|
9468
9494
|
}
|
|
9469
9495
|
const cwdPath = pathImpl.resolve(cwd);
|
|
9470
9496
|
this.roots = /* @__PURE__ */ Object.create(null);
|
|
@@ -10929,7 +10955,7 @@ var Glob = class {
|
|
|
10929
10955
|
if (!opts.cwd) {
|
|
10930
10956
|
this.cwd = "";
|
|
10931
10957
|
} else if (opts.cwd instanceof URL || opts.cwd.startsWith("file://")) {
|
|
10932
|
-
opts.cwd =
|
|
10958
|
+
opts.cwd = fileURLToPath3(opts.cwd);
|
|
10933
10959
|
}
|
|
10934
10960
|
this.cwd = opts.cwd || "";
|
|
10935
10961
|
this.root = opts.root;
|
|
@@ -11242,7 +11268,7 @@ async function analyzeComponentFile(filePath, _options = {}) {
|
|
|
11242
11268
|
});
|
|
11243
11269
|
return analysis;
|
|
11244
11270
|
}
|
|
11245
|
-
const content =
|
|
11271
|
+
const content = readFileSync4(resolve3(filePath), "utf-8");
|
|
11246
11272
|
analysis.size = Buffer.byteLength(content, "utf8");
|
|
11247
11273
|
analysis.lines = content.split("\n").length;
|
|
11248
11274
|
const syntaxAnalysis = analyzeSyntax(content, filePath);
|
|
@@ -11603,7 +11629,7 @@ async function analyzeHydration(options = {}) {
|
|
|
11603
11629
|
}
|
|
11604
11630
|
|
|
11605
11631
|
// src/validators/project-validator.js
|
|
11606
|
-
import { existsSync as existsSync9, readFileSync as
|
|
11632
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "fs";
|
|
11607
11633
|
import { resolve as resolve4 } from "path";
|
|
11608
11634
|
async function validateProject(_options = {}) {
|
|
11609
11635
|
const validation = {
|
|
@@ -11670,7 +11696,7 @@ function validatePackageJson() {
|
|
|
11670
11696
|
const issues = [];
|
|
11671
11697
|
const recommendations = [];
|
|
11672
11698
|
try {
|
|
11673
|
-
const packageJson = JSON.parse(
|
|
11699
|
+
const packageJson = JSON.parse(readFileSync5("package.json", "utf-8"));
|
|
11674
11700
|
const requiredFields = ["name", "version", "description"];
|
|
11675
11701
|
requiredFields.forEach((field) => {
|
|
11676
11702
|
const hasField = packageJson[field];
|
|
@@ -11954,7 +11980,7 @@ async function analyzeConfiguration(_options = {}) {
|
|
|
11954
11980
|
};
|
|
11955
11981
|
if (existsSync10("package.json")) {
|
|
11956
11982
|
try {
|
|
11957
|
-
const packageJson = JSON.parse(
|
|
11983
|
+
const packageJson = JSON.parse(readFileSync6("package.json", "utf-8"));
|
|
11958
11984
|
const hasCoherentDeps = Object.keys(packageJson.dependencies || {}).some((dep) => dep.startsWith("@coherent.js/"));
|
|
11959
11985
|
if (!hasCoherentDeps) {
|
|
11960
11986
|
analysis.summary.issues.push("No Coherent.js dependencies found");
|
|
@@ -12098,12 +12124,12 @@ async function generateHTMLReport(result) {
|
|
|
12098
12124
|
}
|
|
12099
12125
|
|
|
12100
12126
|
// src/index.js
|
|
12101
|
-
var __filename =
|
|
12102
|
-
var __dirname =
|
|
12127
|
+
var __filename = fileURLToPath4(import.meta.url);
|
|
12128
|
+
var __dirname = dirname3(__filename);
|
|
12103
12129
|
var version = "1.0.1";
|
|
12104
12130
|
try {
|
|
12105
|
-
const packagePath =
|
|
12106
|
-
const packageJson = JSON.parse(
|
|
12131
|
+
const packagePath = join8(__dirname, "..", "package.json");
|
|
12132
|
+
const packageJson = JSON.parse(readFileSync7(packagePath, "utf-8"));
|
|
12107
12133
|
version = packageJson.version;
|
|
12108
12134
|
} catch {
|
|
12109
12135
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coherent.js/cli",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "Command-line interface for Coherent.js projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -28,11 +28,8 @@
|
|
|
28
28
|
"node": ">=20.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"chalk": "^5.3.0",
|
|
32
31
|
"commander": "^12.1.0",
|
|
33
|
-
"fs-extra": "^11.2.0",
|
|
34
32
|
"glob": "11.0.3",
|
|
35
|
-
"inquirer": "^10.2.2",
|
|
36
33
|
"ora": "^8.1.0",
|
|
37
34
|
"picocolors": "^1.1.1",
|
|
38
35
|
"prompts": "^2.4.2"
|