ecopages 0.3.1 → 0.4.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.
- package/README.md +1 -1
- package/bin/cli.js +2 -3
- package/bin/init.js +11 -8
- package/bin/launch-plan.js +3 -3
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ The commands above run on Node. Bun is optional: launch them through Bun (`bunx
|
|
|
39
39
|
> [!NOTE]
|
|
40
40
|
> The entry file defaults to `app.ts`. Override it with `--entry-file`.
|
|
41
41
|
|
|
42
|
-
`ecopages start` does not load `eco.config.ts`, so it finds the build output by looking for `.server/manifest.json` one level below the app root (dot-prefixed directories included). It uses the only match, fails with the matches listed when there are several, and fails with "run `ecopages build`" when there is none. Only apps that register API or WebSocket handlers build a server bundle. For a static-only app, `start` instead reports that the build has no server bundle when `dist` (or the `--dist-dir` directory) holds built HTML; serve that output with `ecopages preview` or deploy `dist/` to a static host. Pass `--dist-dir <dir>` to select a directory, which is required for nested (`out/web`) and symlinked outputs and whenever the app builds several outputs, such as `dist-<scope>` per build target.
|
|
42
|
+
`ecopages start` does not load `eco.config.ts`, so it finds the build output by looking for `.server/manifest.json` one level below the app root (dot-prefixed directories included). It uses the only match, fails with the matches listed when there are several, and fails with "run `ecopages build`" when there is none. Only apps that register API or WebSocket handlers or have endpoint files build a server bundle. For a static-only app, `start` instead reports that the build has no server bundle when `dist` (or the `--dist-dir` directory) holds built HTML; serve that output with `ecopages preview` or deploy `dist/` to a static host. Pass `--dist-dir <dir>` to select a directory, which is required for nested (`out/web`) and symlinked outputs and whenever the app builds several outputs, such as `dist-<scope>` per build target.
|
|
43
43
|
|
|
44
44
|
### Templates
|
|
45
45
|
|
package/bin/cli.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
4
3
|
import { spawn } from 'node:child_process';
|
|
5
4
|
import os from 'node:os';
|
|
6
5
|
import path from 'node:path';
|
|
@@ -19,7 +18,7 @@ import { withBrandBanner } from './brand.js';
|
|
|
19
18
|
|
|
20
19
|
const logger = new Logger('[ecopages:cli]', { debug: isEcopagesEnvEnabled('ECOPAGES_LOGGER_DEBUG') });
|
|
21
20
|
|
|
22
|
-
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)
|
|
21
|
+
const pkg = JSON.parse(fileSystem.readFileSync(fileURLToPath(new URL('../package.json', import.meta.url))));
|
|
23
22
|
|
|
24
23
|
const sharedServerOptionDefinitions = {
|
|
25
24
|
port: {
|
|
@@ -288,7 +287,7 @@ async function runEntryCommand(args, options = {}, entryFile = 'app.ts', launchM
|
|
|
288
287
|
const requiresBuiltBundle = launchMode === 'start';
|
|
289
288
|
const superviseDevRestarts = launchMode === 'dev';
|
|
290
289
|
|
|
291
|
-
if (!requiresBuiltBundle && !
|
|
290
|
+
if (!requiresBuiltBundle && !fileSystem.exists(entryFile)) {
|
|
292
291
|
logger.error(`Error: Entry file "${entryFile}" not found in the current directory.`);
|
|
293
292
|
process.exit(1);
|
|
294
293
|
}
|
package/bin/init.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { downloadTemplate } from 'giget';
|
|
2
2
|
import * as prompts from '@clack/prompts';
|
|
3
|
-
import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
4
3
|
import { spawn } from 'node:child_process';
|
|
5
4
|
import { basename, join } from 'node:path';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
6
|
import { parseArgs } from 'node:util';
|
|
7
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
7
8
|
import { printBrandBanner, withBrandBanner } from './brand.js';
|
|
8
9
|
import { normalizeGitSource } from './git-template-source.js';
|
|
9
10
|
|
|
10
|
-
const pkg = JSON.parse(readFileSync(new URL('../package.json', import.meta.url)
|
|
11
|
-
const templateManifest = JSON.parse(
|
|
11
|
+
const pkg = JSON.parse(fileSystem.readFileSync(fileURLToPath(new URL('../package.json', import.meta.url))));
|
|
12
|
+
const templateManifest = JSON.parse(
|
|
13
|
+
fileSystem.readFileSync(fileURLToPath(new URL('../templates.json', import.meta.url))),
|
|
14
|
+
);
|
|
12
15
|
const officialTemplates = [...templateManifest.templates].sort((left, right) => left.order - right.order);
|
|
13
16
|
const defaultOfficialTemplate = officialTemplates.find((template) => template.default) ?? officialTemplates[0];
|
|
14
17
|
|
|
@@ -188,11 +191,11 @@ function rewriteWorkspaceDependencies(projectPkg) {
|
|
|
188
191
|
|
|
189
192
|
function updateProjectManifest(targetDir, packageDirectory, isOfficial) {
|
|
190
193
|
const packagePath = join(targetDir, packageDirectory, 'package.json');
|
|
191
|
-
if (!
|
|
194
|
+
if (!fileSystem.exists(packagePath)) {
|
|
192
195
|
throw new Error(`Template package directory '${packageDirectory}' does not contain a package.json.`);
|
|
193
196
|
}
|
|
194
197
|
|
|
195
|
-
const projectPkg = JSON.parse(readFileSync(packagePath
|
|
198
|
+
const projectPkg = JSON.parse(fileSystem.readFileSync(packagePath));
|
|
196
199
|
projectPkg.name = basename(targetDir);
|
|
197
200
|
if (isOfficial) rewriteWorkspaceDependencies(projectPkg);
|
|
198
201
|
|
|
@@ -208,7 +211,7 @@ function updateProjectManifest(targetDir, packageDirectory, isOfficial) {
|
|
|
208
211
|
}
|
|
209
212
|
}
|
|
210
213
|
|
|
211
|
-
|
|
214
|
+
fileSystem.write(packagePath, `${JSON.stringify(projectPkg, null, 2)}\n`);
|
|
212
215
|
return packagePath;
|
|
213
216
|
}
|
|
214
217
|
|
|
@@ -355,7 +358,7 @@ export async function runInitCommand(rawArgs, logger) {
|
|
|
355
358
|
if (!answers) return;
|
|
356
359
|
|
|
357
360
|
const { dir, templateId, source, packageManager, install, start } = answers;
|
|
358
|
-
if (
|
|
361
|
+
if (fileSystem.exists(dir)) throw new Error(`Target directory already exists: ${dir}`);
|
|
359
362
|
|
|
360
363
|
const officialTemplate = source ? null : findOfficialTemplate(templateId);
|
|
361
364
|
const templateSource = getTemplateSource(templateId, source);
|
|
@@ -386,7 +389,7 @@ export async function runInitCommand(rawArgs, logger) {
|
|
|
386
389
|
`Project initialized. Run 'cd "${relativeCwd}" && ${packageManager} install && ${packageManager} run dev'.`,
|
|
387
390
|
);
|
|
388
391
|
} catch (error) {
|
|
389
|
-
if (targetCreated)
|
|
392
|
+
if (targetCreated) fileSystem.remove(dir);
|
|
390
393
|
throw error;
|
|
391
394
|
}
|
|
392
395
|
}
|
package/bin/launch-plan.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
1
|
import path from 'node:path';
|
|
3
2
|
import { parseEnv } from 'node:util';
|
|
3
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
4
4
|
import {
|
|
5
5
|
resolveEcoConfigPath,
|
|
6
6
|
resolveEmittedEcoConfigPath,
|
|
@@ -14,7 +14,7 @@ const nodeRequirePreload = import.meta.resolve('./node-require-preload.js');
|
|
|
14
14
|
const tsxLoader = import.meta.resolve('tsx/esm');
|
|
15
15
|
|
|
16
16
|
function getEnvFilePaths(nodeEnv) {
|
|
17
|
-
return getDevEnvFileNames(nodeEnv).filter((envFile) =>
|
|
17
|
+
return getDevEnvFileNames(nodeEnv).filter((envFile) => fileSystem.exists(envFile));
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export function buildEnvOverrides(options) {
|
|
@@ -48,7 +48,7 @@ export function resolveEcoConfigFilePath(options = {}, cwd = process.cwd(), reso
|
|
|
48
48
|
export function buildLaunchEnv(options) {
|
|
49
49
|
const envOverrides = buildEnvOverrides(options);
|
|
50
50
|
const envFileValues = getEnvFilePaths(options.nodeEnv).reduce((env, envFile) => {
|
|
51
|
-
return { ...env, ...parseEnv(readFileSync(envFile
|
|
51
|
+
return { ...env, ...parseEnv(fileSystem.readFileSync(envFile)) };
|
|
52
52
|
}, {});
|
|
53
53
|
|
|
54
54
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ecopages",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "CLI utilities for Ecopages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@clack/prompts": "^1.7.0",
|
|
39
|
-
"@ecopages/core": "0.
|
|
40
|
-
"@ecopages/file-system": "0.
|
|
39
|
+
"@ecopages/core": "0.4.0",
|
|
40
|
+
"@ecopages/file-system": "0.4.0",
|
|
41
41
|
"@ecopages/logger": "^0.2.3",
|
|
42
42
|
"giget": "^2.0.0",
|
|
43
43
|
"tsx": "^4.22.3"
|