@mono-labs/cli 0.0.205 → 0.0.206
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/cdk/index.js +6 -2
- package/dist/expo.js +6 -2
- package/dist/merge-env.js +15 -9
- package/dist/project/build-mono-readme.js +38 -33
- package/dist/project/build-readme.js +4 -2
- package/dist/project/generate-docs.js +13 -7
- package/dist/project/generate-readme.js +34 -29
- package/dist/project/index.js +25 -16
- package/dist/project/merge-env.js +15 -9
- package/dist/stack.js +41 -4
- package/dist/tools.js +4 -1
- package/package.json +1 -2
package/dist/cdk/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceTokens = replaceTokens;
|
|
4
|
+
exports.setUpConfig = setUpConfig;
|
|
5
|
+
function replaceTokens(str, env) {
|
|
2
6
|
if (typeof str !== 'string')
|
|
3
7
|
return str;
|
|
4
8
|
return str.replace(/\$\{([^}]+)\}|\$([A-Z0-9_]+)/g, (m, k1, k2) => {
|
|
@@ -26,7 +30,7 @@ function filterEnvByPrefix(env, prefix) {
|
|
|
26
30
|
}
|
|
27
31
|
return filtered;
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
function setUpConfig(config) {
|
|
30
34
|
const { extra = {}, ...other } = config.expo || {};
|
|
31
35
|
const router = extra['router'] ?
|
|
32
36
|
{ origin: false, ...extra['router'] }
|
package/dist/expo.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceTokens = replaceTokens;
|
|
4
|
+
exports.setUpConfig = setUpConfig;
|
|
5
|
+
function replaceTokens(str, env) {
|
|
2
6
|
if (typeof str !== 'string')
|
|
3
7
|
return str;
|
|
4
8
|
return str.replace(/\$\{([^}]+)\}|\$([A-Z0-9_]+)/g, (m, k1, k2) => {
|
|
@@ -26,7 +30,7 @@ function filterEnvByPrefix(env, prefix) {
|
|
|
26
30
|
}
|
|
27
31
|
return filtered;
|
|
28
32
|
}
|
|
29
|
-
|
|
33
|
+
function setUpConfig(config) {
|
|
30
34
|
const { extra = {}, ...other } = config.expo || {};
|
|
31
35
|
const router = extra['router'] ?
|
|
32
36
|
{ origin: false, ...extra['router'] }
|
package/dist/merge-env.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.loadMergedEnv = loadMergedEnv;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
10
|
+
function loadMergedEnv() {
|
|
11
|
+
const ENV_PATH = path_1.default.resolve(process.cwd(), '.env');
|
|
12
|
+
const ENV_LOCAL_PATH = path_1.default.resolve(process.cwd(), '.env.local');
|
|
7
13
|
// Load base .env
|
|
8
|
-
const base =
|
|
14
|
+
const base = fs_1.default.existsSync(ENV_PATH) ? dotenv_1.default.parse(fs_1.default.readFileSync(ENV_PATH)) : {};
|
|
9
15
|
// Load overrides .env.local
|
|
10
|
-
const local =
|
|
11
|
-
|
|
16
|
+
const local = fs_1.default.existsSync(ENV_LOCAL_PATH) ?
|
|
17
|
+
dotenv_1.default.parse(fs_1.default.readFileSync(ENV_LOCAL_PATH))
|
|
12
18
|
: {};
|
|
13
19
|
// Merge: local overrides base
|
|
14
20
|
const merged = {
|
|
@@ -1,28 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// scripts/generate-readme.ts
|
|
2
3
|
// Node >= 18 recommended
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
6
|
+
};
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const generate_docs_js_1 = require("./generate-docs.js");
|
|
6
11
|
/* -------------------------------------------------------------------------- */
|
|
7
12
|
/* Path helpers */
|
|
8
13
|
/* -------------------------------------------------------------------------- */
|
|
9
14
|
// Always use the working directory as the root for all file actions
|
|
10
|
-
const REPO_ROOT =
|
|
11
|
-
const MONO_DIR =
|
|
12
|
-
const ROOT_PKG_JSON =
|
|
13
|
-
const OUTPUT_PATH =
|
|
14
|
-
const OUTPUT_README =
|
|
15
|
+
const REPO_ROOT = node_path_1.default.resolve(process.cwd());
|
|
16
|
+
const MONO_DIR = node_path_1.default.join(REPO_ROOT, '.mono');
|
|
17
|
+
const ROOT_PKG_JSON = node_path_1.default.join(REPO_ROOT, 'package.json');
|
|
18
|
+
const OUTPUT_PATH = node_path_1.default.join(REPO_ROOT, 'docs');
|
|
19
|
+
const OUTPUT_README = node_path_1.default.join(OUTPUT_PATH, 'command-line.md');
|
|
15
20
|
/* -------------------------------------------------------------------------- */
|
|
16
21
|
/* Utils */
|
|
17
22
|
/* -------------------------------------------------------------------------- */
|
|
18
23
|
async function ensureParentDir(filePath) {
|
|
19
24
|
// Always resolve parent dir relative to working directory
|
|
20
|
-
const dir =
|
|
21
|
-
await
|
|
25
|
+
const dir = node_path_1.default.resolve(process.cwd(), node_path_1.default.dirname(filePath));
|
|
26
|
+
await node_fs_1.promises.mkdir(dir, { recursive: true });
|
|
22
27
|
}
|
|
23
28
|
async function exists(p) {
|
|
24
29
|
try {
|
|
25
|
-
await
|
|
30
|
+
await node_fs_1.promises.access(p);
|
|
26
31
|
return true;
|
|
27
32
|
}
|
|
28
33
|
catch {
|
|
@@ -33,18 +38,18 @@ function isObject(v) {
|
|
|
33
38
|
return v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
34
39
|
}
|
|
35
40
|
function toPosix(p) {
|
|
36
|
-
return p.split(
|
|
41
|
+
return p.split(node_path_1.default.sep).join('/');
|
|
37
42
|
}
|
|
38
43
|
async function readJson(filePath) {
|
|
39
44
|
// Always resolve filePath relative to working directory
|
|
40
|
-
const absPath =
|
|
41
|
-
const raw = await
|
|
45
|
+
const absPath = node_path_1.default.resolve(process.cwd(), filePath);
|
|
46
|
+
const raw = await node_fs_1.promises.readFile(absPath, 'utf8');
|
|
42
47
|
return JSON.parse(raw);
|
|
43
48
|
}
|
|
44
49
|
async function listDir(dir) {
|
|
45
50
|
// Always resolve dir relative to working directory
|
|
46
|
-
const absDir =
|
|
47
|
-
return
|
|
51
|
+
const absDir = node_path_1.default.resolve(process.cwd(), dir);
|
|
52
|
+
return node_fs_1.promises.readdir(absDir, { withFileTypes: true });
|
|
48
53
|
}
|
|
49
54
|
function normalizeWorkspacePatterns(workspacesField) {
|
|
50
55
|
if (Array.isArray(workspacesField))
|
|
@@ -81,24 +86,24 @@ async function expandWorkspacePattern(root, pattern) {
|
|
|
81
86
|
const segments = toPosix(pattern).split('/').filter(Boolean);
|
|
82
87
|
async function expandFrom(dir, index) {
|
|
83
88
|
// Always resolve dir relative to working directory
|
|
84
|
-
const absDir =
|
|
89
|
+
const absDir = node_path_1.default.resolve(process.cwd(), dir);
|
|
85
90
|
if (index >= segments.length)
|
|
86
91
|
return [absDir];
|
|
87
92
|
const seg = segments[index];
|
|
88
93
|
if (seg === '**') {
|
|
89
94
|
const results = [];
|
|
90
95
|
results.push(...(await expandFrom(absDir, index + 1)));
|
|
91
|
-
const entries = await
|
|
96
|
+
const entries = await node_fs_1.promises
|
|
92
97
|
.readdir(absDir, { withFileTypes: true })
|
|
93
98
|
.catch(() => []);
|
|
94
99
|
for (const entry of entries) {
|
|
95
100
|
if (!entry.isDirectory())
|
|
96
101
|
continue;
|
|
97
|
-
results.push(...(await expandFrom(
|
|
102
|
+
results.push(...(await expandFrom(node_path_1.default.join(absDir, entry.name), index)));
|
|
98
103
|
}
|
|
99
104
|
return results;
|
|
100
105
|
}
|
|
101
|
-
const entries = await
|
|
106
|
+
const entries = await node_fs_1.promises
|
|
102
107
|
.readdir(absDir, { withFileTypes: true })
|
|
103
108
|
.catch(() => []);
|
|
104
109
|
const results = [];
|
|
@@ -107,14 +112,14 @@ async function expandWorkspacePattern(root, pattern) {
|
|
|
107
112
|
continue;
|
|
108
113
|
if (!matchSegment(seg, entry.name))
|
|
109
114
|
continue;
|
|
110
|
-
results.push(...(await expandFrom(
|
|
115
|
+
results.push(...(await expandFrom(node_path_1.default.join(absDir, entry.name), index + 1)));
|
|
111
116
|
}
|
|
112
117
|
return results;
|
|
113
118
|
}
|
|
114
119
|
const dirs = await expandFrom(root, 0);
|
|
115
120
|
const pkgDirs = [];
|
|
116
121
|
for (const d of dirs) {
|
|
117
|
-
if (await exists(
|
|
122
|
+
if (await exists(node_path_1.default.join(d, 'package.json'))) {
|
|
118
123
|
pkgDirs.push(d);
|
|
119
124
|
}
|
|
120
125
|
}
|
|
@@ -132,7 +137,7 @@ async function findWorkspacePackageDirs(repoRoot, patterns) {
|
|
|
132
137
|
/* -------------------------------------------------------------------------- */
|
|
133
138
|
async function readMonoConfig() {
|
|
134
139
|
// Always resolve configPath relative to working directory
|
|
135
|
-
const configPath =
|
|
140
|
+
const configPath = node_path_1.default.resolve(process.cwd(), node_path_1.default.join(MONO_DIR, 'config.json'));
|
|
136
141
|
if (!(await exists(configPath)))
|
|
137
142
|
return null;
|
|
138
143
|
try {
|
|
@@ -144,18 +149,18 @@ async function readMonoConfig() {
|
|
|
144
149
|
}
|
|
145
150
|
}
|
|
146
151
|
function commandNameFromFile(filePath) {
|
|
147
|
-
return
|
|
152
|
+
return node_path_1.default.basename(filePath).replace(/\.json$/i, '');
|
|
148
153
|
}
|
|
149
154
|
async function readMonoCommands() {
|
|
150
155
|
// Always resolve MONO_DIR relative to working directory
|
|
151
|
-
const monoDirAbs =
|
|
156
|
+
const monoDirAbs = node_path_1.default.resolve(process.cwd(), MONO_DIR);
|
|
152
157
|
if (!(await exists(monoDirAbs)))
|
|
153
158
|
return [];
|
|
154
159
|
const entries = await listDir(monoDirAbs);
|
|
155
160
|
const jsonFiles = entries
|
|
156
161
|
.filter((e) => e.isFile() && e.name.endsWith('.json'))
|
|
157
|
-
.map((e) =>
|
|
158
|
-
.filter((p) =>
|
|
162
|
+
.map((e) => node_path_1.default.join(monoDirAbs, e.name))
|
|
163
|
+
.filter((p) => node_path_1.default.basename(p) !== 'config.json');
|
|
159
164
|
const commands = [];
|
|
160
165
|
for (const file of jsonFiles) {
|
|
161
166
|
try {
|
|
@@ -233,11 +238,11 @@ async function main() {
|
|
|
233
238
|
const packages = [];
|
|
234
239
|
for (const dir of pkgDirs) {
|
|
235
240
|
try {
|
|
236
|
-
const pkg = await readJson(
|
|
241
|
+
const pkg = await readJson(node_path_1.default.join(dir, 'package.json'));
|
|
237
242
|
packages.push({
|
|
238
243
|
name: pkg.name ??
|
|
239
|
-
toPosix(
|
|
240
|
-
|
|
244
|
+
toPosix(node_path_1.default.relative(REPO_ROOT, dir)) ??
|
|
245
|
+
node_path_1.default.basename(dir),
|
|
241
246
|
dir,
|
|
242
247
|
scripts: pkg.scripts ?? {},
|
|
243
248
|
});
|
|
@@ -254,13 +259,13 @@ async function main() {
|
|
|
254
259
|
`);
|
|
255
260
|
// Reuse your existing formatters here
|
|
256
261
|
// (unchanged logic, now fully typed)
|
|
257
|
-
const docsIndex = await generateDocsIndex({
|
|
258
|
-
docsDir:
|
|
262
|
+
const docsIndex = await (0, generate_docs_js_1.generateDocsIndex)({
|
|
263
|
+
docsDir: node_path_1.default.join(REPO_ROOT, 'docs'),
|
|
259
264
|
excludeFile: 'command-line.md',
|
|
260
265
|
});
|
|
261
266
|
parts.push(docsIndex);
|
|
262
267
|
await ensureParentDir(OUTPUT_README);
|
|
263
|
-
await
|
|
268
|
+
await node_fs_1.promises.writeFile(OUTPUT_README, parts.join('\n'), 'utf8');
|
|
264
269
|
console.log(`Generated: ${OUTPUT_README}`);
|
|
265
270
|
console.log(`- mono config: ${monoConfig ? 'yes' : 'no'}`);
|
|
266
271
|
console.log(`- mono commands: ${monoCommands.length}`);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// scripts/generate-repo-help.mjs
|
|
2
3
|
// Generates a developer-friendly workspace command reference.
|
|
3
4
|
//
|
|
@@ -10,18 +11,23 @@
|
|
|
10
11
|
// - Optimize for onboarding and day-to-day use
|
|
11
12
|
// - Keep raw yarn workspace commands for reference
|
|
12
13
|
// - Emphasize `yarn mono` as the primary interface
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.generateDocsIndex = generateDocsIndex;
|
|
19
|
+
const node_fs_1 = require("node:fs");
|
|
20
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
15
21
|
/**
|
|
16
22
|
* Generate a docs index from markdown files.
|
|
17
23
|
*
|
|
18
24
|
* @param options - Options for docs index generation
|
|
19
25
|
* @returns Markdown-formatted index
|
|
20
26
|
*/
|
|
21
|
-
|
|
27
|
+
async function generateDocsIndex({ docsDir, excludeFile, }) {
|
|
22
28
|
// Always resolve docsDir relative to the working directory
|
|
23
|
-
const dirPath =
|
|
24
|
-
const entries = await
|
|
29
|
+
const dirPath = node_path_1.default.resolve(process.cwd(), docsDir);
|
|
30
|
+
const entries = await node_fs_1.promises.readdir(dirPath, { withFileTypes: true });
|
|
25
31
|
const links = [];
|
|
26
32
|
for (const entry of entries) {
|
|
27
33
|
if (!entry.isFile())
|
|
@@ -34,8 +40,8 @@ export async function generateDocsIndex({ docsDir, excludeFile, }) {
|
|
|
34
40
|
// Optionally ignore a caller-specified file
|
|
35
41
|
if (excludeFile && entry.name === excludeFile)
|
|
36
42
|
continue;
|
|
37
|
-
const filePath =
|
|
38
|
-
const contents = await
|
|
43
|
+
const filePath = node_path_1.default.join(dirPath, entry.name);
|
|
44
|
+
const contents = await node_fs_1.promises.readFile(filePath, 'utf8');
|
|
39
45
|
// Find first markdown H1
|
|
40
46
|
const match = contents.match(/^#\s+(.+)$/m);
|
|
41
47
|
if (!match)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
// scripts/generate-repo-help.mjs
|
|
2
3
|
// Generates a developer-friendly workspace command reference.
|
|
3
4
|
//
|
|
@@ -10,20 +11,24 @@
|
|
|
10
11
|
// - Optimize for onboarding and day-to-day use
|
|
11
12
|
// - Keep raw yarn workspace commands for reference
|
|
12
13
|
// - Emphasize `yarn mono` as the primary interface
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
const node_fs_1 = require("node:fs");
|
|
19
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
+
const generate_docs_js_1 = require("./generate-docs.js");
|
|
16
21
|
// ----------------- config -----------------
|
|
17
22
|
// Always use the working directory as the root for all file actions
|
|
18
|
-
const REPO_ROOT =
|
|
19
|
-
const ROOT_PKG_JSON =
|
|
20
|
-
const OUTPUT_PATH =
|
|
23
|
+
const REPO_ROOT = node_path_1.default.resolve(process.cwd());
|
|
24
|
+
const ROOT_PKG_JSON = node_path_1.default.join(REPO_ROOT, 'package.json');
|
|
25
|
+
const OUTPUT_PATH = node_path_1.default.join(REPO_ROOT, 'docs', 'workspaces.md');
|
|
21
26
|
// ----------------- helpers -----------------
|
|
22
27
|
async function exists(p) {
|
|
23
28
|
// Always resolve path relative to working directory
|
|
24
|
-
const absPath =
|
|
29
|
+
const absPath = node_path_1.default.resolve(process.cwd(), p);
|
|
25
30
|
try {
|
|
26
|
-
await
|
|
31
|
+
await node_fs_1.promises.access(absPath);
|
|
27
32
|
return true;
|
|
28
33
|
}
|
|
29
34
|
catch {
|
|
@@ -34,7 +39,7 @@ function isObject(v) {
|
|
|
34
39
|
return v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
35
40
|
}
|
|
36
41
|
function toPosix(p) {
|
|
37
|
-
return p.split(
|
|
42
|
+
return p.split(node_path_1.default.sep).join('/');
|
|
38
43
|
}
|
|
39
44
|
function mdEscapeInline(s) {
|
|
40
45
|
return String(s ?? '').replaceAll('`', '\`');
|
|
@@ -49,8 +54,8 @@ function slugifyForGithubAnchor(title) {
|
|
|
49
54
|
}
|
|
50
55
|
async function readJson(filePath) {
|
|
51
56
|
// Always resolve filePath relative to working directory
|
|
52
|
-
const absPath =
|
|
53
|
-
const raw = await
|
|
57
|
+
const absPath = node_path_1.default.resolve(process.cwd(), filePath);
|
|
58
|
+
const raw = await node_fs_1.promises.readFile(absPath, 'utf8');
|
|
54
59
|
return JSON.parse(raw);
|
|
55
60
|
}
|
|
56
61
|
function normalizeWorkspacePatterns(workspacesField) {
|
|
@@ -75,30 +80,30 @@ async function expandWorkspacePattern(root, pattern) {
|
|
|
75
80
|
const segs = toPosix(pattern).split('/').filter(Boolean);
|
|
76
81
|
async function expandFrom(dir, segIndex) {
|
|
77
82
|
// Always resolve dir relative to working directory
|
|
78
|
-
const absDir =
|
|
83
|
+
const absDir = node_path_1.default.resolve(process.cwd(), dir);
|
|
79
84
|
if (segIndex >= segs.length)
|
|
80
85
|
return [absDir];
|
|
81
86
|
const seg = segs[segIndex];
|
|
82
87
|
if (seg === '**') {
|
|
83
88
|
const results = [];
|
|
84
89
|
results.push(...(await expandFrom(absDir, segIndex + 1)));
|
|
85
|
-
const entries = await
|
|
90
|
+
const entries = await node_fs_1.promises
|
|
86
91
|
.readdir(absDir, { withFileTypes: true })
|
|
87
92
|
.catch(() => []);
|
|
88
93
|
for (const e of entries) {
|
|
89
94
|
if (e.isDirectory()) {
|
|
90
|
-
results.push(...(await expandFrom(
|
|
95
|
+
results.push(...(await expandFrom(node_path_1.default.join(absDir, e.name), segIndex)));
|
|
91
96
|
}
|
|
92
97
|
}
|
|
93
98
|
return results;
|
|
94
99
|
}
|
|
95
|
-
const entries = await
|
|
100
|
+
const entries = await node_fs_1.promises
|
|
96
101
|
.readdir(absDir, { withFileTypes: true })
|
|
97
102
|
.catch(() => []);
|
|
98
103
|
const results = [];
|
|
99
104
|
for (const e of entries) {
|
|
100
105
|
if (e.isDirectory() && matchSegment(seg, e.name)) {
|
|
101
|
-
results.push(...(await expandFrom(
|
|
106
|
+
results.push(...(await expandFrom(node_path_1.default.join(absDir, e.name), segIndex + 1)));
|
|
102
107
|
}
|
|
103
108
|
}
|
|
104
109
|
return results;
|
|
@@ -128,12 +133,12 @@ async function findPackageJsonFilesRecursive(startDir) {
|
|
|
128
133
|
const found = [];
|
|
129
134
|
async function walk(dir) {
|
|
130
135
|
// Always resolve dir relative to working directory
|
|
131
|
-
const absDir =
|
|
132
|
-
const entries = await
|
|
136
|
+
const absDir = node_path_1.default.resolve(process.cwd(), dir);
|
|
137
|
+
const entries = await node_fs_1.promises
|
|
133
138
|
.readdir(absDir, { withFileTypes: true })
|
|
134
139
|
.catch(() => []);
|
|
135
140
|
for (const e of entries) {
|
|
136
|
-
const full =
|
|
141
|
+
const full = node_path_1.default.join(absDir, e.name);
|
|
137
142
|
if (e.isDirectory()) {
|
|
138
143
|
if (!SKIP_DIRS.has(e.name))
|
|
139
144
|
await walk(full);
|
|
@@ -155,13 +160,13 @@ async function collectPackagesFromWorkspaceRoots(workspaceRoots) {
|
|
|
155
160
|
}
|
|
156
161
|
const packages = [];
|
|
157
162
|
for (const file of [...new Set(pkgJsonFiles)]) {
|
|
158
|
-
if (
|
|
163
|
+
if (node_path_1.default.resolve(file) === node_path_1.default.resolve(ROOT_PKG_JSON))
|
|
159
164
|
continue;
|
|
160
165
|
try {
|
|
161
166
|
const pj = await readJson(file);
|
|
162
|
-
const dir =
|
|
167
|
+
const dir = node_path_1.default.dirname(file);
|
|
163
168
|
packages.push({
|
|
164
|
-
name: pj.name || toPosix(
|
|
169
|
+
name: pj.name || toPosix(node_path_1.default.relative(REPO_ROOT, dir)),
|
|
165
170
|
dir,
|
|
166
171
|
scripts: isObject(pj.scripts) ? pj.scripts : {},
|
|
167
172
|
});
|
|
@@ -245,7 +250,7 @@ function formatPackages(packages) {
|
|
|
245
250
|
for (const p of packages) {
|
|
246
251
|
lines.push(`### ${p.name}`);
|
|
247
252
|
lines.push('');
|
|
248
|
-
lines.push(`_Location: \`${toPosix(
|
|
253
|
+
lines.push(`_Location: \`${toPosix(node_path_1.default.relative(REPO_ROOT, p.dir))}\`_`);
|
|
249
254
|
lines.push('');
|
|
250
255
|
const scripts = Object.keys(p.scripts).sort();
|
|
251
256
|
if (!scripts.length) {
|
|
@@ -272,8 +277,8 @@ function formatPackages(packages) {
|
|
|
272
277
|
}
|
|
273
278
|
async function ensureParentDir(filePath) {
|
|
274
279
|
// Always resolve parent dir relative to working directory
|
|
275
|
-
const dir =
|
|
276
|
-
await
|
|
280
|
+
const dir = node_path_1.default.resolve(process.cwd(), node_path_1.default.dirname(filePath));
|
|
281
|
+
await node_fs_1.promises.mkdir(dir, { recursive: true });
|
|
277
282
|
}
|
|
278
283
|
// ----------------- main -----------------
|
|
279
284
|
async function main() {
|
|
@@ -285,7 +290,7 @@ async function main() {
|
|
|
285
290
|
const workspacePatterns = normalizeWorkspacePatterns(rootPkg.workspaces);
|
|
286
291
|
const pkgMgr = `${(rootPkg.packageManager || 'yarn').split('@')[0]} mono`;
|
|
287
292
|
const workspaceRoots = await findWorkspaceRoots(REPO_ROOT, workspacePatterns);
|
|
288
|
-
const fallbackRoots = ['packages', 'apps'].map((p) =>
|
|
293
|
+
const fallbackRoots = ['packages', 'apps'].map((p) => node_path_1.default.join(REPO_ROOT, p));
|
|
289
294
|
const roots = workspaceRoots.length ? workspaceRoots : fallbackRoots;
|
|
290
295
|
const packages = await collectPackagesFromWorkspaceRoots(roots);
|
|
291
296
|
const lines = [];
|
|
@@ -295,13 +300,13 @@ async function main() {
|
|
|
295
300
|
lines.push('## Packages');
|
|
296
301
|
lines.push('');
|
|
297
302
|
lines.push(...formatPackages(packages));
|
|
298
|
-
const val = await generateDocsIndex({
|
|
299
|
-
docsDir:
|
|
303
|
+
const val = await (0, generate_docs_js_1.generateDocsIndex)({
|
|
304
|
+
docsDir: node_path_1.default.join(REPO_ROOT, 'docs'),
|
|
300
305
|
excludeFile: 'workspaces.md',
|
|
301
306
|
});
|
|
302
307
|
val.split('\n').forEach((line) => lines.push(line));
|
|
303
308
|
await ensureParentDir(OUTPUT_PATH);
|
|
304
|
-
await
|
|
309
|
+
await node_fs_1.promises.writeFile(OUTPUT_PATH, lines.join('\n'), 'utf8');
|
|
305
310
|
console.log(`✅ Generated ${OUTPUT_PATH}`);
|
|
306
311
|
console.log(`📦 Packages found: ${packages.length}`);
|
|
307
312
|
}
|
package/dist/project/index.js
CHANGED
|
@@ -1,18 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.loadMergedEnv = exports.loadProjectConfig = void 0;
|
|
7
|
+
exports.detectWorkspaceAndConfigPath = detectWorkspaceAndConfigPath;
|
|
8
|
+
exports.loadAppConfig = loadAppConfig;
|
|
9
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
3
11
|
/**
|
|
4
12
|
* Finds the workspace root by walking up from `startDir`.
|
|
5
13
|
* Works for Yarn/npm workspaces via package.json "workspaces".
|
|
6
14
|
* Also recognizes common mono-repo markers as fallback.
|
|
7
15
|
*/
|
|
8
|
-
|
|
9
|
-
const cwd =
|
|
16
|
+
function detectWorkspaceAndConfigPath(startDir = process.cwd(), configFileName = 'mono.app.json') {
|
|
17
|
+
const cwd = node_path_1.default.resolve(startDir);
|
|
10
18
|
const isWorkspaceRootDir = (dir) => {
|
|
11
19
|
// 1) package.json workspaces
|
|
12
|
-
const pkgPath =
|
|
13
|
-
if (
|
|
20
|
+
const pkgPath = node_path_1.default.join(dir, 'package.json');
|
|
21
|
+
if (node_fs_1.default.existsSync(pkgPath)) {
|
|
14
22
|
try {
|
|
15
|
-
const pkg = JSON.parse(
|
|
23
|
+
const pkg = JSON.parse(node_fs_1.default.readFileSync(pkgPath, 'utf8'));
|
|
16
24
|
if (pkg?.workspaces)
|
|
17
25
|
return true;
|
|
18
26
|
}
|
|
@@ -28,14 +36,14 @@ export function detectWorkspaceAndConfigPath(startDir = process.cwd(), configFil
|
|
|
28
36
|
'nx.json',
|
|
29
37
|
'.git', // good enough for many repos
|
|
30
38
|
];
|
|
31
|
-
return markers.some((m) =>
|
|
39
|
+
return markers.some((m) => node_fs_1.default.existsSync(node_path_1.default.join(dir, m)));
|
|
32
40
|
};
|
|
33
41
|
const findUp = (from, predicate) => {
|
|
34
|
-
let dir =
|
|
42
|
+
let dir = node_path_1.default.resolve(from);
|
|
35
43
|
while (true) {
|
|
36
44
|
if (predicate(dir))
|
|
37
45
|
return dir;
|
|
38
|
-
const parent =
|
|
46
|
+
const parent = node_path_1.default.dirname(dir);
|
|
39
47
|
if (parent === dir)
|
|
40
48
|
return null; // reached filesystem root
|
|
41
49
|
dir = parent;
|
|
@@ -46,23 +54,23 @@ export function detectWorkspaceAndConfigPath(startDir = process.cwd(), configFil
|
|
|
46
54
|
// If we are inside a workspace package, config lives at root.
|
|
47
55
|
// If we're already at root, config lives in cwd (same thing).
|
|
48
56
|
const configDir = workspaceRoot ?? cwd;
|
|
49
|
-
const configPath =
|
|
57
|
+
const configPath = node_path_1.default.join(configDir, configFileName);
|
|
50
58
|
return { cwd, workspaceRoot, isWorkspaceRoot, configDir, configPath };
|
|
51
59
|
}
|
|
52
60
|
const requiredSystemDefaults = {
|
|
53
61
|
ec2User: 'ec2-user',
|
|
54
62
|
regions: ['us-east-1'],
|
|
55
63
|
};
|
|
56
|
-
|
|
64
|
+
function loadAppConfig(configType = 'app', startDir = process.cwd()) {
|
|
57
65
|
const fileName = `mono.${configType}.json`;
|
|
58
66
|
const meta = detectWorkspaceAndConfigPath(startDir, fileName);
|
|
59
|
-
if (!
|
|
67
|
+
if (!node_fs_1.default.existsSync(meta.configPath)) {
|
|
60
68
|
const where = meta.workspaceRoot ?
|
|
61
69
|
`workspace root: ${meta.workspaceRoot}`
|
|
62
70
|
: `cwd: ${meta.cwd}`;
|
|
63
71
|
throw new Error(`Could not find ${fileName} at ${meta.configPath} (detected from ${where}).`);
|
|
64
72
|
}
|
|
65
|
-
const raw =
|
|
73
|
+
const raw = node_fs_1.default.readFileSync(meta.configPath, 'utf8');
|
|
66
74
|
const config = JSON.parse(raw);
|
|
67
75
|
// Apply requiredSystemDefaults for missing/null/undefined values
|
|
68
76
|
if (typeof config === 'object' && config !== null) {
|
|
@@ -76,5 +84,6 @@ export function loadAppConfig(configType = 'app', startDir = process.cwd()) {
|
|
|
76
84
|
}
|
|
77
85
|
return { config, meta };
|
|
78
86
|
}
|
|
79
|
-
|
|
80
|
-
|
|
87
|
+
exports.loadProjectConfig = loadAppConfig;
|
|
88
|
+
var merge_env_js_1 = require("./merge-env.js");
|
|
89
|
+
Object.defineProperty(exports, "loadMergedEnv", { enumerable: true, get: function () { return merge_env_js_1.loadMergedEnv; } });
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.loadMergedEnv = loadMergedEnv;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
10
|
+
function loadMergedEnv() {
|
|
11
|
+
const ENV_PATH = path_1.default.resolve(process.cwd(), '.env');
|
|
12
|
+
const ENV_LOCAL_PATH = path_1.default.resolve(process.cwd(), '.env.local');
|
|
7
13
|
// Load base .env
|
|
8
|
-
const base =
|
|
14
|
+
const base = fs_1.default.existsSync(ENV_PATH) ? dotenv_1.default.parse(fs_1.default.readFileSync(ENV_PATH)) : {};
|
|
9
15
|
// Load overrides .env.local
|
|
10
|
-
const local =
|
|
11
|
-
|
|
16
|
+
const local = fs_1.default.existsSync(ENV_LOCAL_PATH) ?
|
|
17
|
+
dotenv_1.default.parse(fs_1.default.readFileSync(ENV_LOCAL_PATH))
|
|
12
18
|
: {};
|
|
13
19
|
// Merge: local overrides base
|
|
14
20
|
const merged = {
|
package/dist/stack.js
CHANGED
|
@@ -1,9 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.CustomStack = void 0;
|
|
37
|
+
const cdk = __importStar(require("aws-cdk-lib"));
|
|
38
|
+
const merge_env_js_1 = require("./project/merge-env.js");
|
|
39
|
+
(0, merge_env_js_1.loadMergedEnv)();
|
|
4
40
|
//cdk deploy --context owner=cody --context region=us-west-1
|
|
5
41
|
const dev = 'dev';
|
|
6
|
-
|
|
42
|
+
class CustomStack extends cdk.Stack {
|
|
7
43
|
ownerName;
|
|
8
44
|
region;
|
|
9
45
|
domainName;
|
|
@@ -49,3 +85,4 @@ export class CustomStack extends cdk.Stack {
|
|
|
49
85
|
});
|
|
50
86
|
}
|
|
51
87
|
}
|
|
88
|
+
exports.CustomStack = CustomStack;
|
package/dist/tools.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setUpConfig = setUpConfig;
|
|
1
4
|
function filterEnvByPrefix(env, prefix) {
|
|
2
5
|
const filtered = {};
|
|
3
6
|
for (const key in env) {
|
|
@@ -7,7 +10,7 @@ function filterEnvByPrefix(env, prefix) {
|
|
|
7
10
|
}
|
|
8
11
|
return filtered;
|
|
9
12
|
}
|
|
10
|
-
|
|
13
|
+
function setUpConfig(config) {
|
|
11
14
|
const { extra = {}, ...other } = config.expo || {};
|
|
12
15
|
const router = extra['router'] ?
|
|
13
16
|
{ origin: false, ...extra['router'] }
|
package/package.json
CHANGED