codeplay-common 1.3.0 → 1.3.1
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.
|
@@ -61,21 +61,27 @@ try {
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
64
69
|
//In routes.js file check static import START
|
|
70
|
+
|
|
65
71
|
const routesPath = path.join(process.cwd(), 'src', 'js', 'routes.js');
|
|
66
72
|
const routesContent = fs.readFileSync(routesPath, 'utf-8');
|
|
67
73
|
|
|
68
|
-
// Track whether we're inside a block comment
|
|
69
74
|
let inBlockComment = false;
|
|
70
75
|
const lines = routesContent.split('\n');
|
|
71
76
|
|
|
77
|
+
const allowedImport = `import HomePage from '../pages/home.f7';`;
|
|
72
78
|
const badImportRegex = /^[ \t]*import\s+[\w{}*,\s]*\s+from\s+['"].+\.f7['"]\s*;/;
|
|
73
79
|
const badImports = [];
|
|
74
80
|
|
|
75
81
|
lines.forEach((line, index) => {
|
|
76
82
|
const trimmed = line.trim();
|
|
77
83
|
|
|
78
|
-
//
|
|
84
|
+
// Handle block comment start and end
|
|
79
85
|
if (trimmed.startsWith('/*')) inBlockComment = true;
|
|
80
86
|
if (inBlockComment && trimmed.endsWith('*/')) {
|
|
81
87
|
inBlockComment = false;
|
|
@@ -85,28 +91,38 @@ lines.forEach((line, index) => {
|
|
|
85
91
|
// Skip if inside block comment or line comment
|
|
86
92
|
if (inBlockComment || trimmed.startsWith('//')) return;
|
|
87
93
|
|
|
88
|
-
// Match static import
|
|
89
|
-
if (badImportRegex.test(trimmed)) {
|
|
94
|
+
// Match static .f7 import
|
|
95
|
+
if (badImportRegex.test(trimmed) && trimmed !== allowedImport) {
|
|
90
96
|
badImports.push({ line: trimmed, number: index + 1 });
|
|
91
97
|
}
|
|
92
98
|
});
|
|
93
99
|
|
|
94
100
|
if (badImports.length > 0) {
|
|
95
|
-
console.error('\n❌ ERROR: Detected static imports of .f7 files in routes.js\n');
|
|
96
|
-
console.error(`⚠️
|
|
101
|
+
console.error('\n❌ ERROR: Detected disallowed static imports of .f7 files in routes.js\n');
|
|
102
|
+
console.error(`⚠️ Only this static import is allowed:\n ${allowedImport}\n`);
|
|
103
|
+
console.error(`🔧 Please convert other imports to async dynamic imports like this:\n`);
|
|
104
|
+
console.error(`
|
|
105
|
+
|
|
106
|
+
import HomePage from '../pages/home.f7';
|
|
107
|
+
|
|
97
108
|
const routes = [
|
|
98
109
|
{
|
|
99
110
|
path: '/',
|
|
111
|
+
component:HomePage,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
path: '/ProfilePage/',
|
|
100
115
|
async async({ resolve }) {
|
|
101
|
-
const page = await import('../pages/
|
|
116
|
+
const page = await import('../pages/profile.f7');
|
|
102
117
|
resolve({ component: page.default });
|
|
103
118
|
},
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
119
|
+
}]
|
|
120
|
+
`);
|
|
121
|
+
|
|
107
122
|
badImports.forEach(({ line, number }) => {
|
|
108
123
|
console.error(`${number}: ${line}`);
|
|
109
124
|
});
|
|
125
|
+
|
|
110
126
|
process.exit(1);
|
|
111
127
|
} else {
|
|
112
128
|
console.log('✅ routes.js passed the .f7 import check.');
|