@lenne.tech/cli 1.10.0 → 1.11.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.
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ /**
3
+ * Framework-detection helpers for @lenne.tech/nuxt-extensions consumer projects.
4
+ *
5
+ * lenne.tech frontend projects can consume the framework in two modes:
6
+ *
7
+ * - **npm mode** (classic): `@lenne.tech/nuxt-extensions` is installed as an npm
8
+ * dependency. Framework source lives in
9
+ * `node_modules/@lenne.tech/nuxt-extensions/`. The Nuxt config references
10
+ * the module via `modules: ['@lenne.tech/nuxt-extensions']`.
11
+ *
12
+ * - **vendored mode**: The framework's source is copied directly
13
+ * into the project at `<app-root>/app/core/` as first-class project code.
14
+ * There is **no** `@lenne.tech/nuxt-extensions` dependency in `package.json`.
15
+ * The Nuxt config references `modules: ['./app/core/module']`.
16
+ *
17
+ * The detection is driven by the presence of `<app-root>/app/core/VENDOR.md`
18
+ * (a baseline + patch-log file written by the vendoring pipeline).
19
+ *
20
+ * This module centralizes the detection logic so that every CLI command which
21
+ * emits or patches nuxt-extensions-aware code can branch consistently.
22
+ */
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
35
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
36
+ }) : function(o, v) {
37
+ o["default"] = v;
38
+ });
39
+ var __importStar = (this && this.__importStar) || (function () {
40
+ var ownKeys = function(o) {
41
+ ownKeys = Object.getOwnPropertyNames || function (o) {
42
+ var ar = [];
43
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
44
+ return ar;
45
+ };
46
+ return ownKeys(o);
47
+ };
48
+ return function (mod) {
49
+ if (mod && mod.__esModule) return mod;
50
+ var result = {};
51
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
52
+ __setModuleDefault(result, mod);
53
+ return result;
54
+ };
55
+ })();
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.detectFrontendFrameworkMode = detectFrontendFrameworkMode;
58
+ exports.findAppDir = findAppDir;
59
+ exports.getFrontendFrameworkRootPath = getFrontendFrameworkRootPath;
60
+ exports.isVendoredAppProject = isVendoredAppProject;
61
+ const node_fs_1 = require("node:fs");
62
+ const path = __importStar(require("node:path"));
63
+ /**
64
+ * Determines the current frontend framework consumption mode of the given project.
65
+ *
66
+ * Returns `'vendor'` if `VENDOR.md` indicates vendored mode. Otherwise
67
+ * returns `'npm'` (the classic mode where `@lenne.tech/nuxt-extensions` is an
68
+ * npm dependency).
69
+ */
70
+ function detectFrontendFrameworkMode(appDir) {
71
+ return isVendoredAppProject(appDir) ? 'vendor' : 'npm';
72
+ }
73
+ /**
74
+ * Walks up from `startDir` looking for the nearest `nuxt.config.ts` (or
75
+ * `nuxt.config.js`), returning the directory that contains it. Used by
76
+ * commands invoked from a sub-directory of a frontend project.
77
+ *
78
+ * Returns `undefined` if no Nuxt config is found up to the filesystem root.
79
+ */
80
+ function findAppDir(startDir) {
81
+ let current = path.resolve(startDir);
82
+ const root = path.parse(current).root;
83
+ while (current !== root) {
84
+ if ((0, node_fs_1.existsSync)(path.join(current, 'nuxt.config.ts')) ||
85
+ (0, node_fs_1.existsSync)(path.join(current, 'nuxt.config.js'))) {
86
+ return current;
87
+ }
88
+ current = path.dirname(current);
89
+ }
90
+ return undefined;
91
+ }
92
+ /**
93
+ * Returns the filesystem root of the frontend framework source for the project.
94
+ *
95
+ * - npm mode: `<appDir>/node_modules/@lenne.tech/nuxt-extensions`
96
+ * - vendor mode: `<appDir>/app/core`
97
+ *
98
+ * Consumers that need to introspect framework source files should use this
99
+ * instead of hard-coding either path.
100
+ */
101
+ function getFrontendFrameworkRootPath(appDir) {
102
+ return isVendoredAppProject(appDir)
103
+ ? path.join(appDir, 'app', 'core')
104
+ : path.join(appDir, 'node_modules', '@lenne.tech', 'nuxt-extensions');
105
+ }
106
+ /**
107
+ * Detects whether the given frontend project directory runs in vendored mode.
108
+ *
109
+ * A project is considered vendored when:
110
+ * 1. `<appDir>/app/core/VENDOR.md` exists, AND
111
+ * 2. The VENDOR.md content references `@lenne.tech/nuxt-extensions` (guards
112
+ * against coincidental unrelated `VENDOR.md` files).
113
+ *
114
+ * @param appDir Absolute path to the frontend project (the directory that
115
+ * contains `nuxt.config.ts` and `app/`).
116
+ */
117
+ function isVendoredAppProject(appDir) {
118
+ const vendorMd = path.join(appDir, 'app', 'core', 'VENDOR.md');
119
+ if (!(0, node_fs_1.existsSync)(vendorMd)) {
120
+ return false;
121
+ }
122
+ try {
123
+ const content = (0, node_fs_1.readFileSync)(vendorMd, 'utf-8');
124
+ return content.includes('@lenne.tech/nuxt-extensions');
125
+ }
126
+ catch (_a) {
127
+ return false;
128
+ }
129
+ }