meno-core 1.0.54 → 1.1.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.
- package/bin/cli.ts +19 -205
- package/build-astro.ts +31 -27
- package/dist/bin/cli.js +15 -154
- package/dist/bin/cli.js.map +2 -2
- package/dist/chunks/{chunk-3XER4E5W.js → chunk-4ZRU52J2.js} +6 -5
- package/dist/chunks/{chunk-3XER4E5W.js.map → chunk-4ZRU52J2.js.map} +2 -2
- package/dist/chunks/{chunk-NVRBTSQG.js → chunk-5X4HCN7J.js} +4 -4
- package/dist/chunks/chunk-5X4HCN7J.js.map +7 -0
- package/dist/chunks/{chunk-FZITJSSS.js → chunk-7CCVOL5M.js} +14 -14
- package/dist/chunks/chunk-7CCVOL5M.js.map +7 -0
- package/dist/chunks/{chunk-AE3QK5QW.js → chunk-7ZLF4NE5.js} +31 -26
- package/dist/chunks/chunk-7ZLF4NE5.js.map +7 -0
- package/dist/chunks/{chunk-HIZMY3EP.js → chunk-AR7LHIFY.js} +8 -2
- package/dist/chunks/chunk-AR7LHIFY.js.map +7 -0
- package/dist/chunks/{chunk-7HWQUVTU.js → chunk-J4IPTP5X.js} +1839 -443
- package/dist/chunks/chunk-J4IPTP5X.js.map +7 -0
- package/dist/chunks/{chunk-5ETZFREW.js → chunk-QWTQZHG3.js} +186 -79
- package/dist/chunks/chunk-QWTQZHG3.js.map +7 -0
- package/dist/chunks/{chunk-STDY3OVM.js → chunk-XTKNX4FW.js} +3 -3
- package/dist/chunks/{chunk-STDY3OVM.js.map → chunk-XTKNX4FW.js.map} +2 -2
- package/dist/chunks/{fs-ZI5JEU7V.js → fs-G3ANWEFP.js} +2 -2
- package/dist/lib/client/index.js +381 -159
- package/dist/lib/client/index.js.map +3 -3
- package/dist/lib/server/index.js +14365 -6276
- package/dist/lib/server/index.js.map +4 -4
- package/dist/lib/shared/index.js +296 -87
- package/dist/lib/shared/index.js.map +4 -4
- package/dist/lib/shared/richtext/index.js +1 -1
- package/dist/lib/test-utils/index.js +27 -21
- package/dist/lib/test-utils/index.js.map +2 -2
- package/lib/client/ErrorBoundary.test.tsx +147 -90
- package/lib/client/ErrorBoundary.tsx +8 -5
- package/lib/client/componentRegistry.ts +0 -1
- package/lib/client/core/ComponentBuilder.test.ts +150 -0
- package/lib/client/core/ComponentBuilder.ts +112 -12
- package/lib/client/core/ComponentRenderer.test.tsx +1 -2
- package/lib/client/core/builders/embedBuilder.ts +1 -1
- package/lib/client/core/builders/linkBuilder.ts +2 -2
- package/lib/client/core/builders/linkNodeBuilder.ts +1 -1
- package/lib/client/core/builders/listBuilder.ts +41 -4
- package/lib/client/core/builders/localeListBuilder.ts +2 -2
- package/lib/client/core/cmsTemplateProcessor.ts +1 -2
- package/lib/client/hmr/HMRManager.tsx +39 -30
- package/lib/client/hmrCssReload.ts +35 -6
- package/lib/client/hmrWebSocket.ts +5 -5
- package/lib/client/hooks/useColorVariables.ts +12 -9
- package/lib/client/hooks/usePropertyAutocomplete.ts +1 -1
- package/lib/client/hooks/useVariables.ts +3 -1
- package/lib/client/meno-filter/MenoFilter.test.ts +28 -28
- package/lib/client/meno-filter/MenoFilter.ts +9 -6
- package/lib/client/meno-filter/bindings.ts +3 -3
- package/lib/client/meno-filter/init.ts +3 -3
- package/lib/client/meno-filter/renderer.ts +8 -4
- package/lib/client/meno-filter/ui.ts +1 -1
- package/lib/client/meno-filter/updates.ts +3 -2
- package/lib/client/meno-filter/utils.ts +1 -1
- package/lib/client/navigation.test.ts +40 -44
- package/lib/client/responsiveStyleResolver.knownTokens.test.ts +71 -0
- package/lib/client/responsiveStyleResolver.test.ts +5 -5
- package/lib/client/responsiveStyleResolver.ts +61 -4
- package/lib/client/routing/RouteLoader.test.ts +1 -1
- package/lib/client/routing/RouteLoader.ts +8 -3
- package/lib/client/routing/Router.tsx +181 -152
- package/lib/client/scripts/ScriptExecutor.ts +3 -3
- package/lib/client/services/PrefetchService.test.ts +1 -1
- package/lib/client/services/PrefetchService.ts +13 -5
- package/lib/client/styleProcessor.ts +9 -3
- package/lib/client/styles/StyleInjector.ts +1 -1
- package/lib/client/styles/UtilityClassCollector.ts +54 -13
- package/lib/client/templateEngine.test.ts +17 -23
- package/lib/client/templateEngine.ts +7 -13
- package/lib/client/theme.test.ts +1 -1
- package/lib/server/__integration__/server-lifecycle.test.ts +3 -1
- package/lib/server/__integration__/static-assets.test.ts +2 -2
- package/lib/server/__integration__/test-helpers.ts +3 -4
- package/lib/server/astro/cmsPageEmitter.ts +4 -5
- package/lib/server/astro/componentEmitter.ts +11 -8
- package/lib/server/astro/nodeToAstro.test.ts +4 -4
- package/lib/server/astro/nodeToAstro.ts +41 -36
- package/lib/server/astro/normalizeOrphanTemplateProps.test.ts +11 -11
- package/lib/server/astro/normalizeOrphanTemplateProps.ts +7 -6
- package/lib/server/astro/pageEmitter.ts +1 -1
- package/lib/server/astro/templateTransformer.ts +3 -3
- package/lib/server/createServer.ts +2 -2
- package/lib/server/cssGenerator.ts +2 -2
- package/lib/server/fileWatcher.test.ts +41 -4
- package/lib/server/fileWatcher.ts +102 -23
- package/lib/server/index.ts +7 -16
- package/lib/server/jsonLoader.test.ts +3 -3
- package/lib/server/jsonLoader.ts +8 -5
- package/lib/server/middleware/cors.test.ts +1 -1
- package/lib/server/middleware/cors.ts +2 -2
- package/lib/server/middleware/errorHandler.test.ts +2 -2
- package/lib/server/middleware/logger.test.ts +3 -3
- package/lib/server/middleware/logger.ts +7 -7
- package/lib/server/migrateTemplates.ts +3 -3
- package/lib/server/projectContext.ts +1 -1
- package/lib/server/providers/fileSystemCMSProvider.test.ts +18 -4
- package/lib/server/providers/fileSystemCMSProvider.ts +27 -18
- package/lib/server/routes/api/cms.ts +1 -1
- package/lib/server/routes/api/colors.test.ts +2 -2
- package/lib/server/routes/api/components.ts +1 -1
- package/lib/server/routes/api/config.ts +3 -3
- package/lib/server/routes/api/core-routes.ts +2 -2
- package/lib/server/routes/api/enums.test.ts +2 -2
- package/lib/server/routes/api/functions.ts +1 -1
- package/lib/server/routes/api/variables.test.ts +2 -2
- package/lib/server/routes/index.ts +2 -2
- package/lib/server/routes/pages.ts +1 -2
- package/lib/server/routes/static.ts +1 -2
- package/lib/server/runtime/bundler.ts +65 -43
- package/lib/server/runtime/fs.ts +13 -13
- package/lib/server/runtime/httpServer.ts +3 -3
- package/lib/server/services/ColorService.test.ts +3 -3
- package/lib/server/services/ColorService.ts +5 -2
- package/lib/server/services/EnumService.test.ts +2 -2
- package/lib/server/services/EnumService.ts +4 -1
- package/lib/server/services/VariableService.test.ts +7 -7
- package/lib/server/services/VariableService.ts +5 -2
- package/lib/server/services/cmsService.test.ts +44 -44
- package/lib/server/services/cmsService.ts +17 -97
- package/lib/server/services/componentService.test.ts +10 -16
- package/lib/server/services/componentService.ts +20 -12
- package/lib/server/services/configService.test.ts +13 -14
- package/lib/server/services/configService.ts +30 -0
- package/lib/server/services/fileWatcherService.ts +2 -2
- package/lib/server/services/pageService.test.ts +7 -7
- package/lib/server/services/pageService.ts +18 -5
- package/lib/server/ssr/attributeBuilder.ts +2 -2
- package/lib/server/ssr/cmsSSRProcessor.ts +1 -2
- package/lib/server/ssr/errorOverlay.ts +1 -1
- package/lib/server/ssr/htmlGenerator.nonce.test.ts +6 -5
- package/lib/server/ssr/htmlGenerator.test.ts +0 -1
- package/lib/server/ssr/htmlGenerator.ts +25 -9
- package/lib/server/ssr/imageMetadata.ts +2 -2
- package/lib/server/ssr/jsCollector.test.ts +5 -5
- package/lib/server/ssr/liveReloadIntegration.test.ts +7 -8
- package/lib/server/ssr/ssrRenderer.branches.test.ts +9 -9
- package/lib/server/ssr/ssrRenderer.test.ts +150 -15
- package/lib/server/ssr/ssrRenderer.ts +218 -40
- package/lib/server/ssrRenderer.test.ts +6 -6
- package/lib/server/utils/jsonLineMapper.ts +7 -7
- package/lib/server/validateStyleCoverage.ts +0 -1
- package/lib/server/websocketManager.ts +12 -0
- package/lib/shared/breakpoints.test.ts +5 -5
- package/lib/shared/cmsQuery.test.ts +81 -0
- package/lib/shared/cmsQuery.ts +92 -0
- package/lib/shared/cmsQueryParser.ts +11 -7
- package/lib/shared/colorConversions.ts +9 -9
- package/lib/shared/colorVariableUtils.test.ts +22 -0
- package/lib/shared/colorVariableUtils.ts +19 -5
- package/lib/shared/constants.ts +4 -0
- package/lib/shared/cssGeneration.test.ts +33 -0
- package/lib/shared/cssGeneration.ts +50 -35
- package/lib/shared/cssProperties.test.ts +64 -64
- package/lib/shared/cssProperties.ts +2 -2
- package/lib/shared/elementClassName.ts +2 -2
- package/lib/shared/errorLogger.test.ts +12 -12
- package/lib/shared/expressionEvaluator.test.ts +27 -1
- package/lib/shared/expressionEvaluator.ts +9 -0
- package/lib/shared/fontLoader.test.ts +13 -13
- package/lib/shared/fontLoader.ts +2 -2
- package/lib/shared/gradientUtils.test.ts +2 -2
- package/lib/shared/gradientUtils.ts +15 -8
- package/lib/shared/hrefRefs.test.ts +2 -2
- package/lib/shared/hrefRefs.ts +1 -1
- package/lib/shared/i18n.test.ts +3 -3
- package/lib/shared/i18n.ts +5 -4
- package/lib/shared/index.ts +29 -0
- package/lib/shared/inlineSvgStyleRules.ts +12 -9
- package/lib/shared/interactiveStyleMappings.test.ts +21 -21
- package/lib/shared/interactiveStyleMappings.ts +2 -8
- package/lib/shared/interactiveStyles.test.ts +3 -1
- package/lib/shared/itemTemplateUtils.test.ts +5 -5
- package/lib/shared/itemTemplateUtils.ts +9 -5
- package/lib/shared/jsonRepair.ts +8 -8
- package/lib/shared/libraryLoader.test.ts +6 -6
- package/lib/shared/linkUtils.ts +1 -1
- package/lib/shared/logger.test.ts +66 -0
- package/lib/shared/logger.ts +94 -0
- package/lib/shared/markdown.ts +25 -0
- package/lib/shared/nodeUtils.test.ts +13 -9
- package/lib/shared/nodeUtils.ts +27 -4
- package/lib/shared/pathSecurity.ts +1 -1
- package/lib/shared/pathUtils.ts +1 -2
- package/lib/shared/paths/PathConverter.ts +3 -3
- package/lib/shared/paths/PathUtils.ts +4 -3
- package/lib/shared/paths/PathValidator.ts +1 -1
- package/lib/shared/permissions.test.ts +168 -0
- package/lib/shared/permissions.ts +162 -0
- package/lib/shared/propResolver.test.ts +1 -1
- package/lib/shared/propResolver.ts +1 -1
- package/lib/shared/registry/BaseNodeTypeRegistry.test.ts +5 -3
- package/lib/shared/registry/ClientRegistry.ts +0 -1
- package/lib/shared/registry/ComponentRegistry.test.ts +3 -3
- package/lib/shared/registry/ComponentRegistry.ts +6 -1
- package/lib/shared/registry/NodeTypeDefinition.ts +2 -2
- package/lib/shared/registry/SSRRegistry.ts +0 -1
- package/lib/shared/registry/fieldPresets.ts +3 -1
- package/lib/shared/registry/nodeTypes/CustomNodeType.ts +103 -0
- package/lib/shared/registry/nodeTypes/HtmlNodeType.ts +1 -1
- package/lib/shared/registry/nodeTypes/IslandNodeType.ts +129 -0
- package/lib/shared/registry/nodeTypes/ListNodeType.ts +43 -7
- package/lib/shared/registry/nodeTypes/MarkdownNodeType.ts +78 -0
- package/lib/shared/registry/nodeTypes/SlotMarkerType.ts +6 -1
- package/lib/shared/registry/nodeTypes/index.ts +16 -1
- package/lib/shared/responsiveScaling.test.ts +1 -3
- package/lib/shared/responsiveScaling.ts +6 -5
- package/lib/shared/responsiveStyleUtils.test.ts +0 -1
- package/lib/shared/richtext/htmlToTiptap.test.ts +116 -116
- package/lib/shared/richtext/htmlToTiptap.ts +1 -1
- package/lib/shared/styleNodeUtils.ts +17 -14
- package/lib/shared/tailwindThemeScale.ts +256 -0
- package/lib/shared/themeDefaults.test.ts +0 -3
- package/lib/shared/tree/PathBuilder.test.ts +1 -7
- package/lib/shared/tree/PathBuilder.ts +15 -13
- package/lib/shared/treePathUtils.test.ts +49 -2
- package/lib/shared/treePathUtils.ts +40 -4
- package/lib/shared/types/api.ts +105 -7
- package/lib/shared/types/cms.test.ts +34 -0
- package/lib/shared/types/cms.ts +65 -13
- package/lib/shared/types/components.ts +24 -0
- package/lib/shared/types/errors.test.ts +1 -1
- package/lib/shared/types/index.ts +23 -0
- package/lib/shared/types/permissions.ts +139 -0
- package/lib/shared/types/variables.ts +3 -3
- package/lib/shared/utilityClassConfig.ts +219 -0
- package/lib/shared/utilityClassMapper.durability.test.ts +117 -0
- package/lib/shared/utilityClassMapper.test.ts +401 -26
- package/lib/shared/utilityClassMapper.ts +193 -29
- package/lib/shared/utilityClassNames.test.ts +38 -0
- package/lib/shared/utilityClassNames.ts +301 -23
- package/lib/shared/validation/index.ts +1 -0
- package/lib/shared/validation/permissionsValidators.test.ts +49 -0
- package/lib/shared/validation/permissionsValidators.ts +49 -0
- package/lib/shared/validation/propValidator.test.ts +1 -1
- package/lib/shared/validation/propValidator.ts +1 -1
- package/lib/shared/validation/schemas.test.ts +41 -0
- package/lib/shared/validation/schemas.ts +159 -13
- package/lib/shared/validation/validators.test.ts +2 -2
- package/lib/shared/viewportUnits.test.ts +13 -0
- package/lib/shared/viewportUnits.ts +12 -5
- package/lib/test-utils/factories/ConsoleMockFactory.ts +7 -7
- package/lib/test-utils/factories/DomMockFactory.ts +10 -4
- package/lib/test-utils/factories/ServerMockFactory.ts +1 -1
- package/lib/test-utils/factories/StoreMockFactory.ts +5 -5
- package/lib/test-utils/mockFactories.ts +1 -1
- package/lib/test-utils/mocks.ts +3 -3
- package/package.json +3 -5
- package/scripts/build-for-publish.mjs +2 -4
- package/scripts/build-meno-filter.ts +3 -3
- package/tsconfig.json +1 -0
- package/vite.config.ts +1 -1
- package/build-next.ts +0 -1374
- package/build-static.test.ts +0 -453
- package/build-static.ts +0 -1072
- package/dist/build-static.js +0 -37
- package/dist/chunks/chunk-2FN4UOVO.js +0 -6465
- package/dist/chunks/chunk-2FN4UOVO.js.map +0 -7
- package/dist/chunks/chunk-5ETZFREW.js.map +0 -7
- package/dist/chunks/chunk-7E4IF5L7.js +0 -245
- package/dist/chunks/chunk-7E4IF5L7.js.map +0 -7
- package/dist/chunks/chunk-7HWQUVTU.js.map +0 -7
- package/dist/chunks/chunk-AE3QK5QW.js.map +0 -7
- package/dist/chunks/chunk-F6KTJYGV.js +0 -322
- package/dist/chunks/chunk-F6KTJYGV.js.map +0 -7
- package/dist/chunks/chunk-FZITJSSS.js.map +0 -7
- package/dist/chunks/chunk-GSYYA5GX.js +0 -77
- package/dist/chunks/chunk-GSYYA5GX.js.map +0 -7
- package/dist/chunks/chunk-HIZMY3EP.js.map +0 -7
- package/dist/chunks/chunk-I2WEGYA7.js +0 -424
- package/dist/chunks/chunk-I2WEGYA7.js.map +0 -7
- package/dist/chunks/chunk-JNO3CNLJ.js +0 -464
- package/dist/chunks/chunk-JNO3CNLJ.js.map +0 -7
- package/dist/chunks/chunk-NVRBTSQG.js.map +0 -7
- package/dist/chunks/chunk-Q4OBWKXG.js +0 -1143
- package/dist/chunks/chunk-Q4OBWKXG.js.map +0 -7
- package/dist/chunks/chunk-QTE32Y53.js +0 -3829
- package/dist/chunks/chunk-QTE32Y53.js.map +0 -7
- package/dist/chunks/configService-PRJZF7Y6.js +0 -14
- package/dist/chunks/configService-PRJZF7Y6.js.map +0 -7
- package/dist/chunks/constants-KIQEYMAM.js +0 -46
- package/dist/chunks/constants-KIQEYMAM.js.map +0 -7
- package/dist/chunks/fs-ZI5JEU7V.js.map +0 -7
- package/dist/entries/server-router.js +0 -62
- package/dist/entries/server-router.js.map +0 -7
- package/entries/server-router.tsx +0 -75
- package/lib/server/providers/fileSystemPageProvider.test.ts +0 -84
- package/lib/server/providers/fileSystemPageProvider.ts +0 -179
- package/lib/server/webflow/buildWebflow.ts +0 -623
- package/lib/server/webflow/index.ts +0 -23
- package/lib/server/webflow/nodeToWebflow.test.ts +0 -3102
- package/lib/server/webflow/nodeToWebflow.ts +0 -2372
- package/lib/server/webflow/styleMapper.test.ts +0 -348
- package/lib/server/webflow/styleMapper.ts +0 -687
- package/lib/server/webflow/templateWrapper.ts +0 -49
- package/lib/server/webflow/types.ts +0 -389
- /package/dist/{build-static.js.map → chunks/fs-G3ANWEFP.js.map} +0 -0
package/bin/cli.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
3
|
* meno CLI
|
|
4
|
-
*
|
|
4
|
+
*
|
|
5
|
+
* The bespoke JSON renderer (`meno dev`/`build`/`serve`) has been retired — Meno
|
|
6
|
+
* targets Astro exclusively now. The only remaining command is `init` (scaffold a
|
|
7
|
+
* project). To run/build a project, convert it to meno-astro and use the Astro
|
|
8
|
+
* toolchain (`@meno/studio` in the editor, or `astro dev`/`astro build`).
|
|
5
9
|
*/
|
|
6
10
|
|
|
7
|
-
import { resolve, join } from 'path';
|
|
8
|
-
import { existsSync, mkdirSync, writeFileSync, cpSync
|
|
9
|
-
import { setProjectRoot } from '../lib/server/projectContext';
|
|
11
|
+
import { resolve, join } from 'node:path';
|
|
12
|
+
import { existsSync, mkdirSync, writeFileSync, cpSync } from 'node:fs';
|
|
10
13
|
import { migrateI18nConfig } from '../lib/shared/i18n';
|
|
11
14
|
import { syncNetlifyLocale404Block } from '../lib/shared/netlifyLocale404';
|
|
12
|
-
import { generateBuildErrorPage, type BuildErrorsData } from '../lib/server/ssr/buildErrorOverlay';
|
|
13
|
-
import { createRuntimeServer, serveFile, fileExists as runtimeFileExists } from '../lib/server/runtime';
|
|
14
15
|
|
|
15
16
|
const args = process.argv.slice(2);
|
|
16
17
|
const command = args[0];
|
|
17
18
|
|
|
18
19
|
function printHelp() {
|
|
19
20
|
console.log(`
|
|
20
|
-
meno - Visual editor for
|
|
21
|
+
meno - Visual editor for websites (meno-astro)
|
|
21
22
|
|
|
22
23
|
Requirements:
|
|
23
24
|
- Bun or Node.js 18+
|
|
@@ -26,204 +27,20 @@ Usage:
|
|
|
26
27
|
meno <command> [options]
|
|
27
28
|
|
|
28
29
|
Commands:
|
|
29
|
-
dev Start development server with hot reload
|
|
30
|
-
build Build static HTML files for production
|
|
31
|
-
serve Serve built files from ./dist on port 8080
|
|
32
30
|
init Initialize a new project
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
Note:
|
|
33
|
+
The legacy JSON runtime (dev/build/serve) has been retired. Convert a JSON
|
|
34
|
+
project to meno-astro and use the Astro toolchain instead.
|
|
36
35
|
|
|
37
36
|
Examples:
|
|
38
|
-
meno dev Start dev server in current directory
|
|
39
|
-
meno build Build static files to ./dist (excludes drafts)
|
|
40
|
-
meno build --dev Build including draft pages
|
|
41
|
-
meno serve Serve built files on port 8080
|
|
42
37
|
meno init my-project Create new project in ./my-project
|
|
43
38
|
`);
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const headers = new Map<string, Record<string, string>>();
|
|
50
|
-
|
|
51
|
-
if (!existsSync(headersPath)) return headers;
|
|
52
|
-
|
|
53
|
-
const content = readFileSync(headersPath, 'utf-8');
|
|
54
|
-
let currentPath = '';
|
|
55
|
-
|
|
56
|
-
for (const line of content.split('\n')) {
|
|
57
|
-
const trimmed = line.trim();
|
|
58
|
-
if (!trimmed || trimmed.startsWith('#')) continue;
|
|
59
|
-
|
|
60
|
-
if (!line.startsWith(' ') && !line.startsWith('\t')) {
|
|
61
|
-
// Path line
|
|
62
|
-
currentPath = trimmed;
|
|
63
|
-
if (!headers.has(currentPath)) {
|
|
64
|
-
headers.set(currentPath, {});
|
|
65
|
-
}
|
|
66
|
-
} else if (currentPath && trimmed.includes(':')) {
|
|
67
|
-
// Header line
|
|
68
|
-
const colonIndex = trimmed.indexOf(':');
|
|
69
|
-
const name = trimmed.substring(0, colonIndex).trim();
|
|
70
|
-
const value = trimmed.substring(colonIndex + 1).trim();
|
|
71
|
-
headers.get(currentPath)![name] = value;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return headers;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Get headers matching a pathname
|
|
79
|
-
function getMatchingHeaders(pathname: string, headersMap: Map<string, Record<string, string>>): Record<string, string> {
|
|
80
|
-
const result: Record<string, string> = {};
|
|
81
|
-
|
|
82
|
-
headersMap.forEach((headers, pattern) => {
|
|
83
|
-
if (pattern === pathname || pattern === '/*') {
|
|
84
|
-
Object.assign(result, headers);
|
|
85
|
-
} else if (pattern.endsWith('/*')) {
|
|
86
|
-
const prefix = pattern.slice(0, -1);
|
|
87
|
-
if (pathname.startsWith(prefix)) {
|
|
88
|
-
Object.assign(result, headers);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Start static file server on port 8080 (non-blocking)
|
|
97
|
-
async function startStaticServer(distPath: string) {
|
|
98
|
-
const { SERVE_PORT } = await import('../lib/shared/constants');
|
|
99
|
-
|
|
100
|
-
// Parse _headers file once on startup
|
|
101
|
-
const headersMap = parseHeadersFile(distPath);
|
|
102
|
-
|
|
103
|
-
const server = await createRuntimeServer({
|
|
104
|
-
port: SERVE_PORT,
|
|
105
|
-
hostname: 'localhost',
|
|
106
|
-
async fetch(req: Request) {
|
|
107
|
-
const url = new URL(req.url);
|
|
108
|
-
let pathname = url.pathname;
|
|
109
|
-
|
|
110
|
-
// Check for build errors and show overlay (except for _errors.json itself)
|
|
111
|
-
if (pathname !== '/_errors.json') {
|
|
112
|
-
const errorsPath = join(distPath, '_errors.json');
|
|
113
|
-
if (existsSync(errorsPath)) {
|
|
114
|
-
try {
|
|
115
|
-
const errorsData: BuildErrorsData = JSON.parse(readFileSync(errorsPath, 'utf-8'));
|
|
116
|
-
return new Response(generateBuildErrorPage(errorsData), {
|
|
117
|
-
headers: { 'Content-Type': 'text/html; charset=utf-8' },
|
|
118
|
-
});
|
|
119
|
-
} catch {
|
|
120
|
-
// If we can't parse errors file, continue normally
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Default to index.html for root
|
|
126
|
-
if (pathname === '/') {
|
|
127
|
-
pathname = '/index.html';
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Get custom headers for this path
|
|
131
|
-
const customHeaders = getMatchingHeaders(pathname, headersMap);
|
|
132
|
-
|
|
133
|
-
// Try to serve the file
|
|
134
|
-
const filePath = join(distPath, pathname);
|
|
135
|
-
|
|
136
|
-
// Check if file exists and serve it
|
|
137
|
-
if (await runtimeFileExists(filePath)) {
|
|
138
|
-
return await serveFile(filePath, customHeaders);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Try with .html extension for clean URLs
|
|
142
|
-
const htmlPath = filePath.endsWith('.html') ? filePath : `${filePath}.html`;
|
|
143
|
-
if (await runtimeFileExists(htmlPath)) {
|
|
144
|
-
return await serveFile(htmlPath, customHeaders);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// Try index.html in directory
|
|
148
|
-
const indexPath = join(filePath, 'index.html');
|
|
149
|
-
if (await runtimeFileExists(indexPath)) {
|
|
150
|
-
return await serveFile(indexPath, customHeaders);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return new Response('Not Found', { status: 404 });
|
|
154
|
-
},
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
return server;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async function runDev() {
|
|
161
|
-
const projectRoot = process.cwd();
|
|
162
|
-
|
|
163
|
-
// Validate project structure
|
|
164
|
-
if (!existsSync(join(projectRoot, 'pages'))) {
|
|
165
|
-
console.error('❌ No pages directory found. Are you in a valid project directory?');
|
|
166
|
-
console.error(' Run "meno init <project-name>" to create a new project.');
|
|
167
|
-
process.exit(1);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Set project root for path resolution
|
|
171
|
-
setProjectRoot(projectRoot);
|
|
172
|
-
|
|
173
|
-
console.log(`📁 Project root: ${projectRoot}`);
|
|
174
|
-
|
|
175
|
-
// Start static server on 8080 if dist exists
|
|
176
|
-
const distPath = join(projectRoot, 'dist');
|
|
177
|
-
if (existsSync(distPath)) {
|
|
178
|
-
const staticServer = await startStaticServer(distPath);
|
|
179
|
-
console.log(`🚀 Static server running at http://localhost:${staticServer.port}`);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Import and run the dev server (it handles all initialization internally)
|
|
183
|
-
await import('../entries/server-router');
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async function runBuild(isDev: boolean = false) {
|
|
187
|
-
const projectRoot = process.cwd();
|
|
188
|
-
|
|
189
|
-
// Validate project structure
|
|
190
|
-
if (!existsSync(join(projectRoot, 'pages'))) {
|
|
191
|
-
console.error('❌ No pages directory found. Are you in a valid project directory?');
|
|
192
|
-
process.exit(1);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// Set project root for path resolution
|
|
196
|
-
setProjectRoot(projectRoot);
|
|
197
|
-
|
|
198
|
-
// Set dev mode environment variable (drafts are built in dev mode)
|
|
199
|
-
if (isDev) {
|
|
200
|
-
process.env.MENO_DEV_BUILD = 'true';
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
console.log(`📁 Building project: ${projectRoot}${isDev ? ' (dev mode - including drafts)' : ''}`);
|
|
204
|
-
|
|
205
|
-
// Import and run build
|
|
206
|
-
const { buildStaticPages } = await import('../build-static.ts');
|
|
207
|
-
await buildStaticPages();
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async function runServe() {
|
|
211
|
-
const projectRoot = process.cwd();
|
|
212
|
-
const distPath = join(projectRoot, 'dist');
|
|
213
|
-
|
|
214
|
-
// Validate dist directory exists
|
|
215
|
-
if (!existsSync(distPath)) {
|
|
216
|
-
console.error('❌ No dist directory found. Run "meno build" first.');
|
|
217
|
-
process.exit(1);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
console.log(`📁 Serving built files from: ${distPath}`);
|
|
221
|
-
const server = await startStaticServer(distPath);
|
|
222
|
-
console.log(`🚀 Static server running at http://localhost:${server.port}`);
|
|
223
|
-
|
|
224
|
-
// Keep the process alive
|
|
225
|
-
await new Promise(() => {});
|
|
226
|
-
}
|
|
41
|
+
const RETIRED_NOTICE = `The legacy JSON "${command}" command has been retired.
|
|
42
|
+
Meno targets Astro exclusively now. Convert this project to meno-astro and use the
|
|
43
|
+
Astro toolchain instead (open it in @meno/studio, or run "astro dev" / "astro build").`;
|
|
227
44
|
|
|
228
45
|
async function runInit(projectName?: string) {
|
|
229
46
|
if (!projectName) {
|
|
@@ -440,17 +257,14 @@ command = "bun install && bun run build"
|
|
|
440
257
|
|
|
441
258
|
// Main
|
|
442
259
|
switch (command) {
|
|
443
|
-
case '
|
|
444
|
-
|
|
260
|
+
case 'init':
|
|
261
|
+
runInit(args[1]);
|
|
445
262
|
break;
|
|
263
|
+
case 'dev':
|
|
446
264
|
case 'build':
|
|
447
|
-
runBuild(args.includes('--dev'));
|
|
448
|
-
break;
|
|
449
265
|
case 'serve':
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
case 'init':
|
|
453
|
-
runInit(args[1]);
|
|
266
|
+
console.error(RETIRED_NOTICE);
|
|
267
|
+
process.exit(1);
|
|
454
268
|
break;
|
|
455
269
|
case '--help':
|
|
456
270
|
case '-h':
|
package/build-astro.ts
CHANGED
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
* with a shared layout, global CSS, and optional CMS content collections.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { existsSync, readdirSync, mkdirSync, rmSync, statSync, copyFileSync, writeFileSync } from 'fs';
|
|
8
|
-
import { writeFile, readFile } from 'fs/promises';
|
|
9
|
-
import { join } from 'path';
|
|
10
|
-
import { createHash } from 'crypto';
|
|
11
|
-
import { inspect, minifyJS as runtimeMinifyJS } from './lib/server/runtime';
|
|
7
|
+
import { existsSync, readdirSync, mkdirSync, rmSync, statSync, copyFileSync, writeFileSync } from 'node:fs';
|
|
8
|
+
import { writeFile, readFile } from 'node:fs/promises';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
import { createHash } from 'node:crypto';
|
|
12
11
|
import {
|
|
13
12
|
loadJSONFile,
|
|
14
13
|
loadComponentDirectory,
|
|
@@ -16,8 +15,6 @@ import {
|
|
|
16
15
|
parseJSON,
|
|
17
16
|
loadI18nConfig,
|
|
18
17
|
} from './lib/server/jsonLoader';
|
|
19
|
-
import { generateSSRHTML } from './lib/server/ssrRenderer';
|
|
20
|
-
import type { SSRHTMLResult } from './lib/server/ssr/htmlGenerator';
|
|
21
18
|
import { projectPaths } from './lib/server/projectContext';
|
|
22
19
|
import { loadProjectConfig, generateFontCSS, generateFontPreloadTags } from './lib/shared/fontLoader';
|
|
23
20
|
import { FileSystemCMSProvider } from './lib/server/providers/fileSystemCMSProvider';
|
|
@@ -28,10 +25,9 @@ import { tiptapToHtml } from './lib/shared/richtext/tiptapToHtml';
|
|
|
28
25
|
import { isTiptapDocument } from './lib/shared/richtext/types';
|
|
29
26
|
import type { ComponentDefinition, JSONPage, CMSSchema, CMSItem, I18nConfig } from './lib/shared/types';
|
|
30
27
|
import type { CMSFieldDefinition } from './lib/shared/types/cms';
|
|
31
|
-
import { isItemDraftForLocale } from './lib/shared/types';
|
|
32
28
|
import { CMS_DRAFT_SUFFIX } from './lib/shared/pathSecurity';
|
|
33
29
|
import type { SlugMap } from './lib/shared/slugTranslator';
|
|
34
|
-
import { renderPageSSR } from './lib/server/ssr/ssrRenderer';
|
|
30
|
+
import { type PreloadImage, renderPageSSR } from './lib/server/ssr/ssrRenderer';
|
|
35
31
|
import { generateThemeColorVariablesCSS, generateVariablesCSS } from './lib/server/cssGenerator';
|
|
36
32
|
import { colorService } from './lib/server/services/ColorService';
|
|
37
33
|
import { variableService } from './lib/server/services/VariableService';
|
|
@@ -106,7 +102,7 @@ function isCMSPage(pageData: JSONPage): boolean {
|
|
|
106
102
|
/**
|
|
107
103
|
* Build URL path for a CMS item based on the URL pattern
|
|
108
104
|
*/
|
|
109
|
-
function
|
|
105
|
+
function _buildCMSItemPath(
|
|
110
106
|
urlPattern: string,
|
|
111
107
|
item: CMSItem,
|
|
112
108
|
slugField: string,
|
|
@@ -299,8 +295,8 @@ function computeCmsConsumerComponents(components: Record<string, ComponentDefini
|
|
|
299
295
|
function buildCollectionUrlExpr(schema: CMSSchema): string {
|
|
300
296
|
const slugField = schema.slugField || 'slug';
|
|
301
297
|
const pattern = schema.urlPattern || `/${schema.id}/{{slug}}`;
|
|
302
|
-
const body = pattern.replace(/\{\{[^}]+\}\}/,
|
|
303
|
-
return
|
|
298
|
+
const body = pattern.replace(/\{\{[^}]+\}\}/, `\${e.data.${slugField} ?? e.id}`);
|
|
299
|
+
return `\`${body}\``;
|
|
304
300
|
}
|
|
305
301
|
|
|
306
302
|
// ---------------------------------------------------------------------------
|
|
@@ -388,7 +384,7 @@ import BaseLayout from '${importPath}';
|
|
|
388
384
|
// Main export
|
|
389
385
|
// ---------------------------------------------------------------------------
|
|
390
386
|
|
|
391
|
-
export async function buildAstroProject(
|
|
387
|
+
export async function buildAstroProject(_projectRoot?: string, outputDir?: string): Promise<AstroBuildStats> {
|
|
392
388
|
// ----------------------------------------------------------
|
|
393
389
|
// 1. Setup: load project configuration
|
|
394
390
|
// ----------------------------------------------------------
|
|
@@ -510,7 +506,7 @@ export async function buildAstroProject(projectRoot?: string, outputDir?: string
|
|
|
510
506
|
componentCSS?: string;
|
|
511
507
|
locale: string;
|
|
512
508
|
interactiveStylesMap: Map<string, InteractiveStyles>;
|
|
513
|
-
preloadImages:
|
|
509
|
+
preloadImages: PreloadImage[];
|
|
514
510
|
neededCollections: Set<string>;
|
|
515
511
|
ssrFallbackCollector?: Map<string, string>;
|
|
516
512
|
processedRawHtmlCollector?: Map<string, string>;
|
|
@@ -591,7 +587,7 @@ export async function buildAstroProject(projectRoot?: string, outputDir?: string
|
|
|
591
587
|
|
|
592
588
|
// Compute URL path
|
|
593
589
|
let slug: string;
|
|
594
|
-
if (slugs
|
|
590
|
+
if (slugs?.[locale]) {
|
|
595
591
|
// Slugs may be authored with a leading slash (e.g. "/blog" from the
|
|
596
592
|
// page-rename flow). Normalize to the bare form the rest of the
|
|
597
593
|
// pipeline expects — matches buildPageUrlForLocale(). A leading slash
|
|
@@ -632,8 +628,8 @@ export async function buildAstroProject(projectRoot?: string, outputDir?: string
|
|
|
632
628
|
|
|
633
629
|
processRenderResult(result, urlPath, astroFilePath, fileDepth, pageData, pageName, false);
|
|
634
630
|
}
|
|
635
|
-
} catch (error
|
|
636
|
-
console.error(` Error rendering ${basePath}:`, error
|
|
631
|
+
} catch (error) {
|
|
632
|
+
console.error(` Error rendering ${basePath}:`, error instanceof Error ? error.message : error);
|
|
637
633
|
errorCount++;
|
|
638
634
|
}
|
|
639
635
|
}
|
|
@@ -750,6 +746,10 @@ export async function buildAstroProject(projectRoot?: string, outputDir?: string
|
|
|
750
746
|
const cmsSchema = pageData.meta!.cms as CMSSchema;
|
|
751
747
|
templateSchemas.push(cmsSchema);
|
|
752
748
|
|
|
749
|
+
// A data-only collection (no urlPattern) has no per-item route — skip page/route
|
|
750
|
+
// generation. It is still a content collection usable in list bindings.
|
|
751
|
+
if (!cmsSchema.urlPattern) continue;
|
|
752
|
+
|
|
753
753
|
// Count items for stats
|
|
754
754
|
const items = await cmsService.queryItems({ collection: cmsSchema.id });
|
|
755
755
|
const itemCount = items.length;
|
|
@@ -852,8 +852,8 @@ export async function buildAstroProject(projectRoot?: string, outputDir?: string
|
|
|
852
852
|
}
|
|
853
853
|
|
|
854
854
|
cmsPageCount += itemCount * i18nConfig.locales.length;
|
|
855
|
-
} catch (error
|
|
856
|
-
console.error(` Error processing template ${file}:`, error
|
|
855
|
+
} catch (error) {
|
|
856
|
+
console.error(` Error processing template ${file}:`, error instanceof Error ? error.message : error);
|
|
857
857
|
errorCount++;
|
|
858
858
|
}
|
|
859
859
|
}
|
|
@@ -955,7 +955,7 @@ const { title, meta = '', scripts = [], locale = 'en', theme = '${themeConfig.de
|
|
|
955
955
|
// onto each component's interface and forward them from hosts that
|
|
956
956
|
// declare the same prop. See `normalizeOrphanTemplateProps` for details.
|
|
957
957
|
const emittableComponents = normalizeOrphanTemplateProps(globalComponents);
|
|
958
|
-
let
|
|
958
|
+
let _componentFileCount = 0;
|
|
959
959
|
for (const [compName, compDef] of Object.entries(emittableComponents)) {
|
|
960
960
|
try {
|
|
961
961
|
const astroContent = emitAstroComponent(
|
|
@@ -973,9 +973,11 @@ const { title, meta = '', scripts = [], locale = 'en', theme = '${themeConfig.de
|
|
|
973
973
|
},
|
|
974
974
|
);
|
|
975
975
|
await writeFile(join(componentsOutDir, `${compName}.astro`), astroContent, 'utf-8');
|
|
976
|
-
|
|
977
|
-
} catch (error
|
|
978
|
-
console.warn(
|
|
976
|
+
_componentFileCount++;
|
|
977
|
+
} catch (error) {
|
|
978
|
+
console.warn(
|
|
979
|
+
` Warning: could not generate component ${compName}: ${error instanceof Error ? error.message : String(error)}`,
|
|
980
|
+
);
|
|
979
981
|
}
|
|
980
982
|
}
|
|
981
983
|
// ----------------------------------------------------------
|
|
@@ -1026,10 +1028,10 @@ const { title, meta = '', scripts = [], locale = 'en', theme = '${themeConfig.de
|
|
|
1026
1028
|
processedRawHtml: result.processedRawHtmlCollector,
|
|
1027
1029
|
remConfig: remConversionConfig,
|
|
1028
1030
|
});
|
|
1029
|
-
} catch (error
|
|
1031
|
+
} catch (error) {
|
|
1030
1032
|
// Fallback to SSR HTML if component emission fails — needs page-level script
|
|
1031
1033
|
console.warn(
|
|
1032
|
-
` Warning: component emission failed for ${result.urlPath}, using SSR fallback: ${error
|
|
1034
|
+
` Warning: component emission failed for ${result.urlPath}, using SSR fallback: ${error instanceof Error ? error.message : String(error)}`,
|
|
1033
1035
|
);
|
|
1034
1036
|
scriptPaths = writePageScript(result.javascript, scriptsDir);
|
|
1035
1037
|
astroContent = buildSSRFallbackPage(result, importPath, fontPreloads, libraryTags, defaultTheme, scriptPaths);
|
|
@@ -1117,8 +1119,10 @@ export const GET: APIRoute = () => {
|
|
|
1117
1119
|
}
|
|
1118
1120
|
|
|
1119
1121
|
await writeFile(join(collectionDir, itemFile), JSON.stringify(resolved, null, 2), 'utf-8');
|
|
1120
|
-
} catch (err
|
|
1121
|
-
console.warn(
|
|
1122
|
+
} catch (err) {
|
|
1123
|
+
console.warn(
|
|
1124
|
+
` Warning: could not process CMS item ${itemFile}: ${err instanceof Error ? err.message : String(err)}`,
|
|
1125
|
+
);
|
|
1122
1126
|
}
|
|
1123
1127
|
}
|
|
1124
1128
|
}
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,31 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
generateBuildErrorPage
|
|
4
|
-
} from "../chunks/chunk-F6KTJYGV.js";
|
|
5
|
-
import {
|
|
6
|
-
createRuntimeServer,
|
|
7
|
-
setProjectRoot
|
|
8
|
-
} from "../chunks/chunk-JNO3CNLJ.js";
|
|
9
|
-
import {
|
|
10
|
-
fileExists,
|
|
11
|
-
serveFile
|
|
12
|
-
} from "../chunks/chunk-FZITJSSS.js";
|
|
13
2
|
import {
|
|
14
3
|
syncNetlifyLocale404Block
|
|
15
4
|
} from "../chunks/chunk-2AR55GYH.js";
|
|
16
5
|
import {
|
|
17
6
|
migrateI18nConfig
|
|
18
|
-
} from "../chunks/chunk-
|
|
7
|
+
} from "../chunks/chunk-4ZRU52J2.js";
|
|
19
8
|
import "../chunks/chunk-KSBZ2L7C.js";
|
|
20
9
|
|
|
21
10
|
// bin/cli.ts
|
|
22
|
-
import { resolve, join } from "path";
|
|
23
|
-
import { existsSync, mkdirSync, writeFileSync, cpSync
|
|
11
|
+
import { resolve, join } from "node:path";
|
|
12
|
+
import { existsSync, mkdirSync, writeFileSync, cpSync } from "node:fs";
|
|
24
13
|
var args = process.argv.slice(2);
|
|
25
14
|
var command = args[0];
|
|
26
15
|
function printHelp() {
|
|
27
16
|
console.log(`
|
|
28
|
-
meno - Visual editor for
|
|
17
|
+
meno - Visual editor for websites (meno-astro)
|
|
29
18
|
|
|
30
19
|
Requirements:
|
|
31
20
|
- Bun or Node.js 18+
|
|
@@ -34,144 +23,19 @@ Usage:
|
|
|
34
23
|
meno <command> [options]
|
|
35
24
|
|
|
36
25
|
Commands:
|
|
37
|
-
dev Start development server with hot reload
|
|
38
|
-
build Build static HTML files for production
|
|
39
|
-
serve Serve built files from ./dist on port 8080
|
|
40
26
|
init Initialize a new project
|
|
41
27
|
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
Note:
|
|
29
|
+
The legacy JSON runtime (dev/build/serve) has been retired. Convert a JSON
|
|
30
|
+
project to meno-astro and use the Astro toolchain instead.
|
|
44
31
|
|
|
45
32
|
Examples:
|
|
46
|
-
meno dev Start dev server in current directory
|
|
47
|
-
meno build Build static files to ./dist (excludes drafts)
|
|
48
|
-
meno build --dev Build including draft pages
|
|
49
|
-
meno serve Serve built files on port 8080
|
|
50
33
|
meno init my-project Create new project in ./my-project
|
|
51
34
|
`);
|
|
52
35
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (!existsSync(headersPath)) return headers;
|
|
57
|
-
const content = readFileSync(headersPath, "utf-8");
|
|
58
|
-
let currentPath = "";
|
|
59
|
-
for (const line of content.split("\n")) {
|
|
60
|
-
const trimmed = line.trim();
|
|
61
|
-
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
62
|
-
if (!line.startsWith(" ") && !line.startsWith(" ")) {
|
|
63
|
-
currentPath = trimmed;
|
|
64
|
-
if (!headers.has(currentPath)) {
|
|
65
|
-
headers.set(currentPath, {});
|
|
66
|
-
}
|
|
67
|
-
} else if (currentPath && trimmed.includes(":")) {
|
|
68
|
-
const colonIndex = trimmed.indexOf(":");
|
|
69
|
-
const name = trimmed.substring(0, colonIndex).trim();
|
|
70
|
-
const value = trimmed.substring(colonIndex + 1).trim();
|
|
71
|
-
headers.get(currentPath)[name] = value;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
return headers;
|
|
75
|
-
}
|
|
76
|
-
function getMatchingHeaders(pathname, headersMap) {
|
|
77
|
-
const result = {};
|
|
78
|
-
headersMap.forEach((headers, pattern) => {
|
|
79
|
-
if (pattern === pathname || pattern === "/*") {
|
|
80
|
-
Object.assign(result, headers);
|
|
81
|
-
} else if (pattern.endsWith("/*")) {
|
|
82
|
-
const prefix = pattern.slice(0, -1);
|
|
83
|
-
if (pathname.startsWith(prefix)) {
|
|
84
|
-
Object.assign(result, headers);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
return result;
|
|
89
|
-
}
|
|
90
|
-
async function startStaticServer(distPath) {
|
|
91
|
-
const { SERVE_PORT } = await import("../chunks/constants-KIQEYMAM.js");
|
|
92
|
-
const headersMap = parseHeadersFile(distPath);
|
|
93
|
-
const server = await createRuntimeServer({
|
|
94
|
-
port: SERVE_PORT,
|
|
95
|
-
hostname: "localhost",
|
|
96
|
-
async fetch(req) {
|
|
97
|
-
const url = new URL(req.url);
|
|
98
|
-
let pathname = url.pathname;
|
|
99
|
-
if (pathname !== "/_errors.json") {
|
|
100
|
-
const errorsPath = join(distPath, "_errors.json");
|
|
101
|
-
if (existsSync(errorsPath)) {
|
|
102
|
-
try {
|
|
103
|
-
const errorsData = JSON.parse(readFileSync(errorsPath, "utf-8"));
|
|
104
|
-
return new Response(generateBuildErrorPage(errorsData), {
|
|
105
|
-
headers: { "Content-Type": "text/html; charset=utf-8" }
|
|
106
|
-
});
|
|
107
|
-
} catch {
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (pathname === "/") {
|
|
112
|
-
pathname = "/index.html";
|
|
113
|
-
}
|
|
114
|
-
const customHeaders = getMatchingHeaders(pathname, headersMap);
|
|
115
|
-
const filePath = join(distPath, pathname);
|
|
116
|
-
if (await fileExists(filePath)) {
|
|
117
|
-
return await serveFile(filePath, customHeaders);
|
|
118
|
-
}
|
|
119
|
-
const htmlPath = filePath.endsWith(".html") ? filePath : `${filePath}.html`;
|
|
120
|
-
if (await fileExists(htmlPath)) {
|
|
121
|
-
return await serveFile(htmlPath, customHeaders);
|
|
122
|
-
}
|
|
123
|
-
const indexPath = join(filePath, "index.html");
|
|
124
|
-
if (await fileExists(indexPath)) {
|
|
125
|
-
return await serveFile(indexPath, customHeaders);
|
|
126
|
-
}
|
|
127
|
-
return new Response("Not Found", { status: 404 });
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
return server;
|
|
131
|
-
}
|
|
132
|
-
async function runDev() {
|
|
133
|
-
const projectRoot = process.cwd();
|
|
134
|
-
if (!existsSync(join(projectRoot, "pages"))) {
|
|
135
|
-
console.error("\u274C No pages directory found. Are you in a valid project directory?");
|
|
136
|
-
console.error(' Run "meno init <project-name>" to create a new project.');
|
|
137
|
-
process.exit(1);
|
|
138
|
-
}
|
|
139
|
-
setProjectRoot(projectRoot);
|
|
140
|
-
console.log(`\u{1F4C1} Project root: ${projectRoot}`);
|
|
141
|
-
const distPath = join(projectRoot, "dist");
|
|
142
|
-
if (existsSync(distPath)) {
|
|
143
|
-
const staticServer = await startStaticServer(distPath);
|
|
144
|
-
console.log(`\u{1F680} Static server running at http://localhost:${staticServer.port}`);
|
|
145
|
-
}
|
|
146
|
-
await import("../entries/server-router.js");
|
|
147
|
-
}
|
|
148
|
-
async function runBuild(isDev = false) {
|
|
149
|
-
const projectRoot = process.cwd();
|
|
150
|
-
if (!existsSync(join(projectRoot, "pages"))) {
|
|
151
|
-
console.error("\u274C No pages directory found. Are you in a valid project directory?");
|
|
152
|
-
process.exit(1);
|
|
153
|
-
}
|
|
154
|
-
setProjectRoot(projectRoot);
|
|
155
|
-
if (isDev) {
|
|
156
|
-
process.env.MENO_DEV_BUILD = "true";
|
|
157
|
-
}
|
|
158
|
-
console.log(`\u{1F4C1} Building project: ${projectRoot}${isDev ? " (dev mode - including drafts)" : ""}`);
|
|
159
|
-
const { buildStaticPages } = await import("../build-static.js");
|
|
160
|
-
await buildStaticPages();
|
|
161
|
-
}
|
|
162
|
-
async function runServe() {
|
|
163
|
-
const projectRoot = process.cwd();
|
|
164
|
-
const distPath = join(projectRoot, "dist");
|
|
165
|
-
if (!existsSync(distPath)) {
|
|
166
|
-
console.error('\u274C No dist directory found. Run "meno build" first.');
|
|
167
|
-
process.exit(1);
|
|
168
|
-
}
|
|
169
|
-
console.log(`\u{1F4C1} Serving built files from: ${distPath}`);
|
|
170
|
-
const server = await startStaticServer(distPath);
|
|
171
|
-
console.log(`\u{1F680} Static server running at http://localhost:${server.port}`);
|
|
172
|
-
await new Promise(() => {
|
|
173
|
-
});
|
|
174
|
-
}
|
|
36
|
+
var RETIRED_NOTICE = `The legacy JSON "${command}" command has been retired.
|
|
37
|
+
Meno targets Astro exclusively now. Convert this project to meno-astro and use the
|
|
38
|
+
Astro toolchain instead (open it in @meno/studio, or run "astro dev" / "astro build").`;
|
|
175
39
|
async function runInit(projectName) {
|
|
176
40
|
if (!projectName) {
|
|
177
41
|
console.error("\u274C Please provide a project name: meno init <project-name>");
|
|
@@ -358,17 +222,14 @@ command = "bun install && bun run build"
|
|
|
358
222
|
console.log("");
|
|
359
223
|
}
|
|
360
224
|
switch (command) {
|
|
361
|
-
case "
|
|
362
|
-
|
|
225
|
+
case "init":
|
|
226
|
+
runInit(args[1]);
|
|
363
227
|
break;
|
|
228
|
+
case "dev":
|
|
364
229
|
case "build":
|
|
365
|
-
runBuild(args.includes("--dev"));
|
|
366
|
-
break;
|
|
367
230
|
case "serve":
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
case "init":
|
|
371
|
-
runInit(args[1]);
|
|
231
|
+
console.error(RETIRED_NOTICE);
|
|
232
|
+
process.exit(1);
|
|
372
233
|
break;
|
|
373
234
|
case "--help":
|
|
374
235
|
case "-h":
|