@aravinthan_p/appnest-engine 1.0.20 → 1.0.22
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/README.md +73 -62
- package/appnest-command-line/appnest-command.js +41 -28
- package/appnest-command-line/frameworkDocsUtils.js +73 -0
- package/appnest-command-line/precheckUtils.js +7 -20
- package/appnest-command-line/setupAppUtils.js +15 -0
- package/appnest-command-line/validateUtils/index.js +2 -8
- package/appnest-command-line/validateUtils/lint/lint-backend.js +4 -3
- package/appnest-command-line/validateUtils/lint/lint-frontend.js +4 -4
- package/appnest-command-line/validateUtils/lint/lint-utils.js +67 -56
- package/appnest-command-line/validateUtils/lint/lint.js +5 -5
- package/appnest-command-line/validateUtils/manifestUtils.js +359 -120
- package/appnest-command-line/zipUtils.js +1 -1
- package/appnest-engine-commands.md +46 -0
- package/appnest-install-frontend/package.json +1 -1
- package/appnest-install-frontend/vite.config.js +4 -4
- package/appnest-proxy/server.js +20 -14
- package/cli.js +6 -4
- package/package.json +3 -1
|
@@ -2,53 +2,46 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const path = require('path');
|
|
5
|
+
const js = require('@eslint/js');
|
|
6
|
+
const globals = require('globals');
|
|
5
7
|
|
|
6
8
|
const SKIP_FOLDERS = ['node_modules', 'dist'];
|
|
7
9
|
const BACKEND_EXTENSIONS = ['.js'];
|
|
8
10
|
const FRONTEND_EXTENSIONS = ['.js', '.jsx', '.css'];
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Image: 'readonly',
|
|
44
|
-
history: 'readonly',
|
|
45
|
-
screen: 'readonly',
|
|
46
|
-
alert: 'readonly',
|
|
47
|
-
confirm: 'readonly',
|
|
48
|
-
prompt: 'readonly',
|
|
49
|
-
atob: 'readonly',
|
|
50
|
-
btoa: 'readonly',
|
|
51
|
-
};
|
|
12
|
+
/**
|
|
13
|
+
* app-backend policy: CommonJS only (`require`, `module.exports`, `exports.*`).
|
|
14
|
+
* Not flagged (and expected): `module.exports.foo = fn` — that is CommonJS, not ESM.
|
|
15
|
+
* Blocked: `import` / `export` / `import()` AST nodes via `no-restricted-syntax`.
|
|
16
|
+
* Also blocked at parse time (`sourceType: 'script'`): top-level `import`/`export`, `import.meta`.
|
|
17
|
+
*/
|
|
18
|
+
const BACKEND_COMMONJS_ONLY_FORBID_ESM = [
|
|
19
|
+
{
|
|
20
|
+
selector: 'ImportDeclaration',
|
|
21
|
+
message:
|
|
22
|
+
'app-backend is CommonJS-only — use require(), not import.',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
selector: 'ExportNamedDeclaration',
|
|
26
|
+
message:
|
|
27
|
+
'app-backend is CommonJS-only — use module.exports / exports, not export { }.',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
selector: 'ExportDefaultDeclaration',
|
|
31
|
+
message:
|
|
32
|
+
'app-backend is CommonJS-only — use module.exports, not export default.',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
selector: 'ExportAllDeclaration',
|
|
36
|
+
message:
|
|
37
|
+
'app-backend is CommonJS-only — use CommonJS re-exports, not export *.',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
selector: 'ImportExpression',
|
|
41
|
+
message:
|
|
42
|
+
'app-backend is CommonJS-only — use require(), not dynamic import().',
|
|
43
|
+
},
|
|
44
|
+
];
|
|
52
45
|
|
|
53
46
|
/**
|
|
54
47
|
* Recursively find files with allowed extensions under dir, skipping certain folders.
|
|
@@ -83,44 +76,62 @@ function constructLintMessage(filename, lint) {
|
|
|
83
76
|
}
|
|
84
77
|
|
|
85
78
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
79
|
+
* Flat ESLint config for app-backend: CommonJS only for backend `.js` sources.
|
|
80
|
+
* - Allowed: require(), module.exports, exports, normal JS (async/await, const, etc.).
|
|
81
|
+
* - Rejected: ESM import / export / import() (see BACKEND_COMMONJS_ONLY_FORBID_ESM).
|
|
82
|
+
* @returns {import('eslint').Linter.Config[]}
|
|
83
|
+
*/
|
|
84
|
+
const getEslintBackendConfig = () => [
|
|
85
|
+
js.configs.recommended,
|
|
86
|
+
{
|
|
87
|
+
files: ['**/*.js'],
|
|
88
|
+
languageOptions: {
|
|
89
|
+
ecmaVersion: 2022,
|
|
90
|
+
sourceType: 'script',
|
|
91
|
+
parserOptions: { ecmaVersion: 2022 },
|
|
92
|
+
globals: globals.node,
|
|
93
|
+
},
|
|
94
|
+
rules: {
|
|
95
|
+
'no-restricted-syntax': ['error', ...BACKEND_COMMONJS_ONLY_FORBID_ESM],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Flat ESLint config for app-frontend / app-install-frontend (.js, .jsx).
|
|
102
|
+
* @param {string} filename - Used to enable JSX parsing for `.jsx` files.
|
|
103
|
+
* @returns {import('eslint').Linter.Config[]}
|
|
89
104
|
*/
|
|
90
|
-
|
|
91
|
-
const resolved = path.resolve(filename);
|
|
92
|
-
const isFrontend = frontendPath && resolved.startsWith(path.resolve(frontendPath));
|
|
93
|
-
const globals = isFrontend ? BROWSER_GLOBALS : NODE_GLOBALS;
|
|
105
|
+
const getEslintFrontendConfig = (filename) => {
|
|
94
106
|
const isJsx = path.extname(filename).toLowerCase() === '.jsx';
|
|
95
107
|
return [
|
|
96
108
|
{
|
|
97
109
|
// Explicit files so .jsx is matched (ESLint default only matches **/*.js, **/*.mjs)
|
|
98
110
|
files: ['**/*.js', '**/*.jsx'],
|
|
111
|
+
...js.configs.recommended,
|
|
99
112
|
languageOptions: {
|
|
100
113
|
ecmaVersion: 2022,
|
|
101
114
|
sourceType: 'module',
|
|
102
115
|
parserOptions: {
|
|
103
116
|
ecmaVersion: 2022,
|
|
104
|
-
ecmaFeatures: { jsx:
|
|
117
|
+
ecmaFeatures: { jsx: isJsx },
|
|
105
118
|
},
|
|
106
|
-
globals,
|
|
119
|
+
globals: globals.browser,
|
|
107
120
|
},
|
|
108
121
|
rules: {
|
|
109
122
|
'no-unused-vars': ['warn', { argsIgnorePattern: '^_' }],
|
|
110
|
-
'no-undef': 'error',
|
|
111
123
|
'no-implicit-globals': 'error',
|
|
112
124
|
},
|
|
113
125
|
},
|
|
114
126
|
];
|
|
115
|
-
}
|
|
127
|
+
};
|
|
116
128
|
|
|
117
129
|
module.exports = {
|
|
118
130
|
SKIP_FOLDERS,
|
|
119
131
|
BACKEND_EXTENSIONS,
|
|
120
132
|
FRONTEND_EXTENSIONS,
|
|
121
|
-
NODE_GLOBALS,
|
|
122
|
-
BROWSER_GLOBALS,
|
|
123
133
|
spider,
|
|
124
134
|
constructLintMessage,
|
|
125
|
-
|
|
135
|
+
getEslintBackendConfig,
|
|
136
|
+
getEslintFrontendConfig,
|
|
126
137
|
};
|
|
@@ -16,7 +16,7 @@ const validate = async ({ projects = {}, fix = false } = {}) => {
|
|
|
16
16
|
const userDir = process.cwd();
|
|
17
17
|
const appBackendPath = path.resolve(userDir, projects['app-backend'] || 'app-backend');
|
|
18
18
|
const appFrontendPath = path.resolve(userDir, projects['app-frontend'] || 'app-frontend');
|
|
19
|
-
const appInstallationFrontendPath = path.resolve(userDir, projects['app-
|
|
19
|
+
const appInstallationFrontendPath = path.resolve(userDir, projects['app-install-frontend'] || 'app-install-frontend');
|
|
20
20
|
|
|
21
21
|
console.log('📂 User Directory:', userDir);
|
|
22
22
|
console.log('📂 App Backend Path:', appBackendPath);
|
|
@@ -37,7 +37,7 @@ const validate = async ({ projects = {}, fix = false } = {}) => {
|
|
|
37
37
|
}
|
|
38
38
|
if (fs.existsSync(appInstallationFrontendPath)) {
|
|
39
39
|
const installationFrontendLints = await lintFrontend(appInstallationFrontendPath, fix);
|
|
40
|
-
reportLints({ lints: installationFrontendLints, projectName: 'app-
|
|
40
|
+
reportLints({ lints: installationFrontendLints, projectName: 'app-install-frontend', projectPath: appInstallationFrontendPath });
|
|
41
41
|
lints.push(...installationFrontendLints);
|
|
42
42
|
}
|
|
43
43
|
return lints;
|
|
@@ -49,13 +49,13 @@ const validate = async ({ projects = {}, fix = false } = {}) => {
|
|
|
49
49
|
|
|
50
50
|
const reportLints = ({ lints, projectName, projectPath }) => {
|
|
51
51
|
if (lints.length === 0 && !fs.existsSync(projectPath)) {
|
|
52
|
-
console.log(
|
|
52
|
+
console.log(`📦 ${projectName} project folder not found to lint.`);
|
|
53
53
|
return [];
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const errors = lints.filter((l) => l.severity === 2);
|
|
57
57
|
const warnings = lints.filter((l) => l.severity === 1);
|
|
58
|
-
console.log(
|
|
58
|
+
console.log(`🏁 Lint report begins for ${projectName} project folder.`);
|
|
59
59
|
if (errors.length) {
|
|
60
60
|
console.log(`\n❌ Lint errors (${errors.length}):`);
|
|
61
61
|
errors.forEach((l) => console.log(' ', l.value));
|
|
@@ -67,7 +67,7 @@ const reportLints = ({ lints, projectName, projectPath }) => {
|
|
|
67
67
|
if (errors.length === 0 && warnings.length === 0) {
|
|
68
68
|
console.log(lints.length > 0 ? '✅ Lint passed with no issues.' : '📋 No lintable files found.');
|
|
69
69
|
}
|
|
70
|
-
console.log(
|
|
70
|
+
console.log(`🏁 Lint report ends for ${projectName} project folder.`);
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
module.exports = {
|