ecopages 0.6.1 → 0.7.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/README.md CHANGED
@@ -22,7 +22,7 @@ pnpm install
22
22
  pnpm dev
23
23
  ```
24
24
 
25
- The commands above run on Node. Bun is optional: launch them through Bun (`bunx ecopages init`, `bun dev`) or pass `--runtime bun` to run the app on Bun.
25
+ The commands above run on Node.js `^24.22.0 || >=26.0.0`; the CLI exits with an error on any other version. Bun is optional: launch them through Bun (`bunx ecopages init`, `bun dev`) or pass `--runtime bun` to run the app on Bun.
26
26
 
27
27
  ## Commands
28
28
 
@@ -50,7 +50,7 @@ ecopages init my-site --template jsx
50
50
  ecopages init my-site --from github:acme/my-template#v1.0.0
51
51
  ```
52
52
 
53
- The official template IDs are `jsx`, `html`, `react`, `react-shadcn`, `lit-jsx`, `radiant`, `blog-jsx`, `blog-react`, `docs-starter`, `react-better-auth`, and `llm-wiki`.
53
+ The official template IDs are `jsx`, `jsx-postcss`, `jsx-css-modules`, `html`, `react`, `react-postcss`, `react-shadcn`, `lit-jsx`, `radiant`, `blog-jsx`, `blog-react`, `docs-starter`, `react-better-auth`, and `llm-wiki`.
54
54
 
55
55
  ## Environment & Runtime Options
56
56
 
package/bin/cli.js CHANGED
@@ -2,23 +2,25 @@
2
2
 
3
3
  import { spawn } from 'node:child_process';
4
4
  import os from 'node:os';
5
- import path from 'node:path';
6
- import { fileURLToPath } from 'node:url';
5
+ import { path } from '@ecopages/file-system/path';
7
6
  import { parseArgs } from 'node:util';
8
7
  import { Logger } from '@ecopages/logger';
9
8
  import { createLaunchPlan, resolveEcoConfigFilePath } from './launch-plan.js';
10
9
  import {
11
10
  ECOPAGES_DEV_RESTART_EXIT_CODE,
12
11
  ECOPAGES_DEV_RESTART_REASON_ENV,
12
+ ENTRY_COMMAND_FLAGS,
13
+ getEntryCommandFlagNames,
13
14
  isEcopagesEnvEnabled,
14
15
  resolveDevelopmentRecoveryWatch,
15
16
  } from '@ecopages/core/build';
16
17
  import { fileSystem } from '@ecopages/file-system';
17
18
  import { withBrandBanner } from './brand.js';
19
+ import { getUnsupportedNodeMessage } from './node-version.js';
18
20
 
19
21
  const logger = new Logger('[ecopages:cli]', { debug: isEcopagesEnvEnabled('ECOPAGES_LOGGER_DEBUG') });
20
22
 
21
- const pkg = JSON.parse(fileSystem.readFileSync(fileURLToPath(new URL('../package.json', import.meta.url))));
23
+ const pkg = JSON.parse(fileSystem.readFileSync(path.fromFileUrl(new URL('../package.json', import.meta.url))));
22
24
 
23
25
  const sharedServerOptionDefinitions = {
24
26
  port: {
@@ -112,11 +114,11 @@ function parseCommandArguments(rawArgs, options) {
112
114
  function parseServerCommandArgs(rawArgs, definition) {
113
115
  const commandName = definition.name;
114
116
  const valueOptions = definition.valueOptions ?? {};
115
- const booleanOptions = definition.booleanOptions ?? {};
117
+ const entryFlagNames = getEntryCommandFlagNames(commandName);
116
118
  const { values, positionals } = parseCommandArguments(rawArgs, {
117
119
  ...sharedServerOptionDefinitions,
118
120
  ...Object.fromEntries(Object.keys(valueOptions).map((option) => [option, { type: 'string' }])),
119
- ...booleanOptions,
121
+ ...Object.fromEntries(entryFlagNames.map((flag) => [flag, { type: 'boolean' }])),
120
122
  });
121
123
 
122
124
  if (values.help) {
@@ -124,7 +126,10 @@ function parseServerCommandArgs(rawArgs, definition) {
124
126
  getServerCommandHelpText(
125
127
  commandName,
126
128
  definition.description,
127
- [...Object.values(valueOptions), ...(definition.optionHelpLines ?? [])],
129
+ [
130
+ ...Object.values(valueOptions),
131
+ ...entryFlagNames.map((flag) => ` --${flag.padEnd(33)}${ENTRY_COMMAND_FLAGS[flag].help}`),
132
+ ],
128
133
  definition.ignoredOptions,
129
134
  ),
130
135
  );
@@ -141,7 +146,7 @@ function parseServerCommandArgs(rawArgs, definition) {
141
146
 
142
147
  return {
143
148
  entry,
144
- keepGoing: Boolean(values['keep-going']),
149
+ entryFlags: entryFlagNames.filter((flag) => values[flag]),
145
150
  options: {
146
151
  port: values.port,
147
152
  hostname: values.hostname,
@@ -338,7 +343,7 @@ async function runServerCommand(rawArgs, definition) {
338
343
 
339
344
  const entry = definition.resolveEntry?.() ?? parsed.entry;
340
345
  const entryArgs = [...definition.entryArgs];
341
- if (parsed.keepGoing) entryArgs.push('--keep-going');
346
+ for (const flag of parsed.entryFlags) entryArgs.push(`--${flag}`);
342
347
  await runEntryCommand(
343
348
  entryArgs,
344
349
  { ...parsed.options, ...definition.optionOverrides, entryFile: entry },
@@ -368,8 +373,6 @@ const SERVER_COMMANDS = {
368
373
  description:
369
374
  'Build the project for production: pre-render the Pages in src/pages, optimize assets and images, and write the result to dist.',
370
375
  entryArgs: ['--build'],
371
- booleanOptions: { 'keep-going': { type: 'boolean' } },
372
- optionHelpLines: [' --keep-going Continue the build after a Page fails to render'],
373
376
  optionOverrides: { nodeEnv: 'production' },
374
377
  },
375
378
  start: {
@@ -385,7 +388,7 @@ const SERVER_COMMANDS = {
385
388
  description:
386
389
  'Load eco.config.ts so processors write the types for virtual modules such as ecopages:images, then exit. The app entry does not run. Run it before tsc.',
387
390
  entryArgs: [],
388
- resolveEntry: () => fileURLToPath(import.meta.resolve('@ecopages/core/config/write-types')),
391
+ resolveEntry: () => path.fromFileUrl(import.meta.resolve('@ecopages/core/config/write-types')),
389
392
  ignoredOptions: ['port', 'hostname', 'base-url', 'entry-file'],
390
393
  optionOverrides: { nodeEnv: 'production' },
391
394
  },
@@ -399,6 +402,12 @@ const SERVER_COMMANDS = {
399
402
  export async function runCli(rawArgs = process.argv.slice(2)) {
400
403
  const [commandName, ...commandArgs] = rawArgs;
401
404
 
405
+ const unsupportedNodeMessage = getUnsupportedNodeMessage();
406
+ if (unsupportedNodeMessage) {
407
+ logger.error(unsupportedNodeMessage);
408
+ process.exit(1);
409
+ }
410
+
402
411
  if (!commandName || commandName === '--help' || commandName === '-h') {
403
412
  console.log(withBrandBanner(pkg.version, getMainHelpText()));
404
413
  return;
package/bin/init.js CHANGED
@@ -1,16 +1,15 @@
1
1
  import { downloadTemplate } from 'giget';
2
2
  import * as prompts from '@clack/prompts';
3
3
  import { spawn } from 'node:child_process';
4
- import { basename, join } from 'node:path';
5
- import { fileURLToPath } from 'node:url';
4
+ import { path } from '@ecopages/file-system/path';
6
5
  import { parseArgs } from 'node:util';
7
6
  import { fileSystem } from '@ecopages/file-system';
8
7
  import { printBrandBanner, withBrandBanner } from './brand.js';
9
8
  import { normalizeGitSource } from './git-template-source.js';
10
9
 
11
- const pkg = JSON.parse(fileSystem.readFileSync(fileURLToPath(new URL('../package.json', import.meta.url))));
10
+ const pkg = JSON.parse(fileSystem.readFileSync(path.fromFileUrl(new URL('../package.json', import.meta.url))));
12
11
  const templateManifest = JSON.parse(
13
- fileSystem.readFileSync(fileURLToPath(new URL('../templates.json', import.meta.url))),
12
+ fileSystem.readFileSync(path.fromFileUrl(new URL('../templates.json', import.meta.url))),
14
13
  );
15
14
  const officialTemplates = [...templateManifest.templates].sort((left, right) => left.order - right.order);
16
15
  const defaultOfficialTemplate = officialTemplates.find((template) => template.default) ?? officialTemplates[0];
@@ -190,13 +189,13 @@ function rewriteWorkspaceDependencies(projectPkg) {
190
189
  }
191
190
 
192
191
  function updateProjectManifest(targetDir, packageDirectory, isOfficial) {
193
- const packagePath = join(targetDir, packageDirectory, 'package.json');
192
+ const packagePath = path.join(targetDir, packageDirectory, 'package.json');
194
193
  if (!fileSystem.exists(packagePath)) {
195
194
  throw new Error(`Template package directory '${packageDirectory}' does not contain a package.json.`);
196
195
  }
197
196
 
198
197
  const projectPkg = JSON.parse(fileSystem.readFileSync(packagePath));
199
- projectPkg.name = basename(targetDir);
198
+ projectPkg.name = path.basename(targetDir);
200
199
  if (isOfficial) rewriteWorkspaceDependencies(projectPkg);
201
200
 
202
201
  if (isOfficial) {
@@ -374,7 +373,7 @@ export async function runInitCommand(rawArgs, logger) {
374
373
  updateProjectManifest(dir, packageDirectory, Boolean(officialTemplate));
375
374
  prompts.log.step(`Project created in ${dir}.`);
376
375
 
377
- const packageCwd = join(dir, packageDirectory);
376
+ const packageCwd = path.join(dir, packageDirectory);
378
377
  if (install) {
379
378
  prompts.log.step(`Installing dependencies with ${packageManager}...`);
380
379
  await runChildCommand(packageManager, ['install'], packageCwd);
@@ -384,7 +383,7 @@ export async function runInitCommand(rawArgs, logger) {
384
383
  await runChildCommand(packageManager, ['run', 'dev'], packageCwd);
385
384
  }
386
385
 
387
- const relativeCwd = packageDirectory === '.' ? dir : join(dir, packageDirectory);
386
+ const relativeCwd = packageDirectory === '.' ? dir : path.join(dir, packageDirectory);
388
387
  logger.info(
389
388
  `Project initialized. Run 'cd "${relativeCwd}" && ${packageManager} install && ${packageManager} run dev'.`,
390
389
  );
@@ -1,5 +1,4 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
1
+ import { path } from '@ecopages/file-system/path';
3
2
  import { parseEnv } from 'node:util';
4
3
  import { fileSystem } from '@ecopages/file-system';
5
4
  import {
@@ -14,7 +13,7 @@ import { ECOPAGES_ENTRY_WATCH_ENV, getDevEnvFileNames, getEcopagesEnv } from '@e
14
13
  const nodeRequirePreload = import.meta.resolve('./node-require-preload.js');
15
14
  const tsxLoader = import.meta.resolve('tsx/esm');
16
15
  const viewReferencePreload = import.meta.resolve('./view-reference-preload.js');
17
- const viewReferencePreloadPath = fileURLToPath(viewReferencePreload);
16
+ const viewReferencePreloadPath = path.fromFileUrl(viewReferencePreload);
18
17
 
19
18
  function getEnvFilePaths(nodeEnv) {
20
19
  return getDevEnvFileNames(nodeEnv).filter((envFile) => fileSystem.exists(envFile));
@@ -30,7 +29,7 @@ export function buildEnvOverrides(options) {
30
29
  if (options.configFile) {
31
30
  env.ECOPAGES_CONFIG_FILE = path.isAbsolute(options.configFile)
32
31
  ? options.configFile
33
- : path.resolve(process.cwd(), options.configFile);
32
+ : path.resolve(path.cwd(), options.configFile);
34
33
  }
35
34
  if (options.watch) {
36
35
  env[ECOPAGES_ENTRY_WATCH_ENV] = '1';
@@ -38,7 +37,7 @@ export function buildEnvOverrides(options) {
38
37
  return env;
39
38
  }
40
39
 
41
- export function resolveEcoConfigFilePath(options = {}, cwd = process.cwd(), resolverOptions = {}) {
40
+ export function resolveEcoConfigFilePath(options = {}, cwd = path.cwd(), resolverOptions = {}) {
42
41
  return resolveEcoConfigPath({
43
42
  configFile: options.configFile,
44
43
  cwd,
@@ -138,23 +137,23 @@ export async function createLaunchPlan(args, options, entryFile, launchMode) {
138
137
  const resolvedLaunchMode = inferLaunchMode(args, launchMode);
139
138
  const shouldUseBundle = usesProductionBundle(resolvedLaunchMode);
140
139
  const distDir = shouldUseBundle
141
- ? await resolveProductionDistDir({ cwd: process.cwd(), distDir: resolvedOptions.distDir })
140
+ ? await resolveProductionDistDir({ cwd: path.cwd(), distDir: resolvedOptions.distDir })
142
141
  : undefined;
143
142
  const isExplicitConfig = Boolean(resolvedOptions.configFile || getEcopagesEnv('ECOPAGES_CONFIG_FILE'));
144
- const resolvedConfigFile = resolveEcoConfigFilePath(resolvedOptions, process.cwd(), {
143
+ const resolvedConfigFile = resolveEcoConfigFilePath(resolvedOptions, path.cwd(), {
145
144
  preferEmitted: shouldUseBundle && !isExplicitConfig,
146
145
  distDir,
147
146
  });
148
147
 
149
148
  if (shouldUseBundle) {
150
- const distServerApp = resolveProductionServerEntry(process.cwd(), distDir);
149
+ const distServerApp = resolveProductionServerEntry(path.cwd(), distDir);
151
150
  if (!distServerApp) {
152
151
  throw new Error(
153
- `Production server entry not found in ${path.relative(process.cwd(), distDir) || '.'}. Run \`ecopages build\` again.`,
152
+ `Production server entry not found in ${path.relative(path.cwd(), distDir) || '.'}. Run \`ecopages build\` again.`,
154
153
  );
155
154
  }
156
- const runtimeConfigFile = resolveEmittedEcoConfigPath(process.cwd(), distDir) ?? resolvedConfigFile;
157
- assertProductionConfigIdentity(process.cwd(), runtimeConfigFile, {
155
+ const runtimeConfigFile = resolveEmittedEcoConfigPath(path.cwd(), distDir) ?? resolvedConfigFile;
156
+ assertProductionConfigIdentity(path.cwd(), runtimeConfigFile, {
158
157
  distDir,
159
158
  });
160
159
  if (runtimeConfigFile) {
@@ -1,4 +1,4 @@
1
- import path from 'node:path';
1
+ import { path } from '@ecopages/file-system/path';
2
2
  import { createRequire } from 'node:module';
3
3
 
4
- globalThis.require = createRequire(path.join(process.cwd(), 'package.json'));
4
+ globalThis.require = createRequire(path.join(path.cwd(), 'package.json'));
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The Node.js range Ecopages supports, as written in every package's `engines.node`.
3
+ */
4
+ export const SUPPORTED_NODE_RANGE = '^24.22.0 || >=26.0.0';
5
+
6
+ /**
7
+ * Returns an error message when the running Node.js is outside {@link SUPPORTED_NODE_RANGE}, or `undefined` when it is supported.
8
+ *
9
+ * @remarks
10
+ * Bun reports its own Node compatibility version in `process.versions.node`, which is not a Node release, so a Bun
11
+ * launch is never checked.
12
+ */
13
+ export function getUnsupportedNodeMessage(versions = process.versions) {
14
+ if (versions.bun) return undefined;
15
+
16
+ const [major = 0, minor = 0] = String(versions.node).split('.').map(Number);
17
+ const supported = major >= 26 || (major === 24 && minor >= 22);
18
+ if (supported) return undefined;
19
+
20
+ return `Ecopages requires Node.js ${SUPPORTED_NODE_RANGE}, but this is Node.js ${versions.node}. Upgrade Node.js and run the command again.`;
21
+ }
@@ -1,10 +1,11 @@
1
- import path from 'node:path';
2
- import { fileURLToPath } from 'node:url';
1
+ import { path } from '@ecopages/file-system/path';
3
2
  import { loadEcoPagesUserConfig } from '@ecopages/core/config';
3
+ import { fileSystem } from '@ecopages/file-system';
4
4
  import {
5
5
  collectViewIntegrations,
6
6
  findViewOwner,
7
7
  isExemptFromViewReference,
8
+ isViewModule,
8
9
  viewExtensionFilter,
9
10
  viewReferenceModuleSource,
10
11
  } from '@ecopages/core/view-reference';
@@ -16,12 +17,12 @@ async function loadViewRewriteContext() {
16
17
  const { config } = await loadEcoPagesUserConfig();
17
18
  return {
18
19
  integrations: collectViewIntegrations(config.integrations ?? []),
19
- appRoot: config.rootDir ?? process.cwd(),
20
+ appRoot: config.rootDir ?? path.cwd(),
20
21
  };
21
22
  } catch {
22
23
  return {
23
24
  integrations: collectViewIntegrations([]),
24
- appRoot: process.cwd(),
25
+ appRoot: path.cwd(),
25
26
  };
26
27
  }
27
28
  }
@@ -44,7 +45,7 @@ function importerFilePath(importer) {
44
45
  }
45
46
  if (importer.startsWith('file:')) {
46
47
  try {
47
- return fileURLToPath(importer);
48
+ return path.fromFileUrl(importer);
48
49
  } catch {
49
50
  return null;
50
51
  }
@@ -52,20 +53,33 @@ function importerFilePath(importer) {
52
53
  return importer;
53
54
  }
54
55
 
56
+ /**
57
+ * Resolves an import the way Bun does, so tsconfig aliases reach the file.
58
+ *
59
+ * @remarks
60
+ * `Bun.resolveSync` does not run plugins. A specifier Bun cannot resolve is left to
61
+ * the import itself to report.
62
+ */
55
63
  function resolveImportedPath(specifier, importer, appRoot) {
56
- if (path.isAbsolute(specifier)) {
57
- return specifier;
58
- }
59
64
  const importerPath = importerFilePath(importer);
60
65
  const fromDir = importerPath ? path.dirname(importerPath) : appRoot;
61
- return path.resolve(fromDir, specifier);
66
+ try {
67
+ return globalThis.Bun.resolveSync(specifier, fromDir);
68
+ } catch {
69
+ return undefined;
70
+ }
62
71
  }
63
72
 
73
+ /** The Integration whose view this import is, or `undefined` when the file loads as itself. */
64
74
  function viewOwnerToRewrite(filePath, entryPath, appRoot) {
65
75
  if (isExemptFromViewReference(filePath, { entryPath, appRoot })) {
66
76
  return undefined;
67
77
  }
68
- return findViewOwner(integrations, filePath);
78
+ const owner = findViewOwner(integrations, filePath);
79
+ if (!owner || !isViewModule(filePath, fileSystem.readFileSync(filePath))) {
80
+ return undefined;
81
+ }
82
+ return owner;
69
83
  }
70
84
 
71
85
  function viewModuleLoadResult(filePath, integrationName) {
@@ -88,7 +102,7 @@ if (process.versions.bun) {
88
102
  setup(builder) {
89
103
  builder.onResolve({ filter: viewExtensionFilter(extensions) }, (args) => {
90
104
  const filePath = resolveImportedPath(args.path, args.importer, appRoot);
91
- const owner = viewOwnerToRewrite(filePath, entryPath, appRoot);
105
+ const owner = filePath ? viewOwnerToRewrite(filePath, entryPath, appRoot) : undefined;
92
106
  if (!owner) {
93
107
  return undefined;
94
108
  }
@@ -114,7 +128,7 @@ if (process.versions.bun) {
114
128
 
115
129
  let filePath;
116
130
  try {
117
- filePath = fileURLToPath(url);
131
+ filePath = path.fromFileUrl(url);
118
132
  } catch {
119
133
  return nextLoad(url, context);
120
134
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "ecopages",
3
- "version": "0.6.1",
3
+ "version": "0.7.1",
4
4
  "description": "CLI utilities for Ecopages",
5
5
  "type": "module",
6
6
  "engines": {
7
- "node": ">=24.0.0"
7
+ "node": "^24.22.0 || >=26.0.0"
8
8
  },
9
9
  "license": "MIT",
10
10
  "author": "Ecopages Team",
@@ -36,8 +36,8 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@clack/prompts": "^1.7.0",
39
- "@ecopages/core": "0.6.1",
40
- "@ecopages/file-system": "0.6.1",
39
+ "@ecopages/core": "0.7.1",
40
+ "@ecopages/file-system": "0.7.1",
41
41
  "@ecopages/logger": "^0.2.3",
42
42
  "giget": "^2.0.0",
43
43
  "tsx": "^4.22.3"
package/templates.json CHANGED
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "id": "jsx",
5
5
  "displayName": "JSX",
6
- "description": "A minimal Ecopages JSX application.",
6
+ "description": "A minimal Ecopages JSX application with Tailwind v4 on Lightning CSS.",
7
7
  "category": "integration",
8
8
  "order": 10,
9
9
  "default": true,
@@ -11,6 +11,26 @@
11
11
  "packageDirectory": ".",
12
12
  "integrations": ["ecopages-jsx", "mdx"]
13
13
  },
14
+ {
15
+ "id": "jsx-postcss",
16
+ "displayName": "JSX PostCSS",
17
+ "description": "The JSX application with Tailwind v4 run by PostCSS, for PostCSS plugins and Tailwind v3.",
18
+ "category": "integration",
19
+ "order": 11,
20
+ "source": "jsx-postcss",
21
+ "packageDirectory": ".",
22
+ "integrations": ["ecopages-jsx", "mdx", "postcss"]
23
+ },
24
+ {
25
+ "id": "jsx-css-modules",
26
+ "displayName": "JSX CSS Modules",
27
+ "description": "The JSX application styled with plain CSS Modules on Lightning CSS, without Tailwind.",
28
+ "category": "integration",
29
+ "order": 12,
30
+ "source": "jsx-css-modules",
31
+ "packageDirectory": ".",
32
+ "integrations": ["ecopages-jsx", "mdx", "lightningcss"]
33
+ },
14
34
  {
15
35
  "id": "html",
16
36
  "displayName": "HTML",
@@ -24,13 +44,23 @@
24
44
  {
25
45
  "id": "react",
26
46
  "displayName": "React",
27
- "description": "A minimal Ecopages React application.",
47
+ "description": "A minimal Ecopages React application with Tailwind v4 on Lightning CSS.",
28
48
  "category": "integration",
29
49
  "order": 20,
30
50
  "source": "react",
31
51
  "packageDirectory": ".",
32
52
  "integrations": ["react"]
33
53
  },
54
+ {
55
+ "id": "react-postcss",
56
+ "displayName": "React PostCSS",
57
+ "description": "The React application with Tailwind v4 run by PostCSS, for PostCSS plugins and Tailwind v3.",
58
+ "category": "integration",
59
+ "order": 21,
60
+ "source": "react-postcss",
61
+ "packageDirectory": ".",
62
+ "integrations": ["react", "postcss"]
63
+ },
34
64
  {
35
65
  "id": "react-shadcn",
36
66
  "displayName": "React shadcn",