ecopages 0.2.1 → 0.3.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 +109 -47
- package/bin/brand.js +42 -0
- package/bin/cli.js +348 -192
- package/bin/git-template-source-providers.js +56 -0
- package/bin/git-template-source-shared.js +7 -0
- package/bin/git-template-source.js +62 -0
- package/bin/init.js +392 -0
- package/bin/launch-plan.js +156 -60
- package/bin/node-require-preload.js +4 -0
- package/css/view-transitions.css +3 -6
- package/package.json +13 -12
- package/templates.json +115 -0
- package/bin/cli.test.ts +0 -136
- package/bin/launch-plan.test.ts +0 -160
package/bin/launch-plan.test.ts
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { tmpdir } from 'node:os';
|
|
5
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
|
6
|
-
import {
|
|
7
|
-
buildEnvOverrides,
|
|
8
|
-
buildBunArgs,
|
|
9
|
-
buildNodeArgs,
|
|
10
|
-
createLaunchPlan,
|
|
11
|
-
detectRuntime,
|
|
12
|
-
launchPlanRequiresExistingEntryFile,
|
|
13
|
-
resolveTsxCliPath,
|
|
14
|
-
} from './launch-plan.js';
|
|
15
|
-
|
|
16
|
-
const require = createRequire(import.meta.url);
|
|
17
|
-
|
|
18
|
-
const originalUserAgent = process.env.npm_config_user_agent;
|
|
19
|
-
|
|
20
|
-
afterEach(() => {
|
|
21
|
-
if (originalUserAgent === undefined) {
|
|
22
|
-
delete process.env.npm_config_user_agent;
|
|
23
|
-
} else {
|
|
24
|
-
process.env.npm_config_user_agent = originalUserAgent;
|
|
25
|
-
}
|
|
26
|
-
process.chdir('/Users/andeeplus/github/ecopages');
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('launch-plan', () => {
|
|
30
|
-
function writeExperimentalRuntimeConfig(tempDir) {
|
|
31
|
-
fs.writeFileSync(
|
|
32
|
-
path.join(tempDir, 'eco.config.ts'),
|
|
33
|
-
[
|
|
34
|
-
'const rootDir = process.cwd();',
|
|
35
|
-
'export default {',
|
|
36
|
-
'\trootDir,',
|
|
37
|
-
'\tloaders: new Map(),',
|
|
38
|
-
'\tabsolutePaths: {',
|
|
39
|
-
'\t\tconfig: `${rootDir}/eco.config.ts`,',
|
|
40
|
-
'\t\tsrcDir: `${rootDir}/src`,',
|
|
41
|
-
'\t\tdistDir: `${rootDir}/dist`,',
|
|
42
|
-
'\t\tworkDir: `${rootDir}/.eco`,',
|
|
43
|
-
'\t},',
|
|
44
|
-
'\truntime: {},',
|
|
45
|
-
'};',
|
|
46
|
-
].join('\n'),
|
|
47
|
-
'utf8',
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
it('buildEnvOverrides maps CLI options onto environment variables', () => {
|
|
52
|
-
expect(
|
|
53
|
-
buildEnvOverrides({
|
|
54
|
-
port: 4173,
|
|
55
|
-
hostname: '127.0.0.1',
|
|
56
|
-
baseUrl: 'https://example.test',
|
|
57
|
-
debug: true,
|
|
58
|
-
nodeEnv: 'production',
|
|
59
|
-
}),
|
|
60
|
-
).toEqual({
|
|
61
|
-
ECOPAGES_PORT: '4173',
|
|
62
|
-
ECOPAGES_HOSTNAME: '127.0.0.1',
|
|
63
|
-
ECOPAGES_BASE_URL: 'https://example.test',
|
|
64
|
-
ECOPAGES_LOGGER_DEBUG: 'true',
|
|
65
|
-
NODE_ENV: 'production',
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('detectRuntime returns node when Bun is not available', () => {
|
|
70
|
-
process.env.npm_config_user_agent = 'pnpm/10.0.0 npm/? node/v24.0.0 darwin arm64';
|
|
71
|
-
expect(detectRuntime()).toBe('node');
|
|
72
|
-
expect(detectRuntime({ runtime: 'bun' })).toBe('bun');
|
|
73
|
-
expect(detectRuntime({ runtime: 'node' })).toBe('node');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('buildBunArgs preloads eco.config.ts when present', () => {
|
|
77
|
-
expect(buildBunArgs(['--dev'], { hot: true }, 'app.ts', true)).toEqual([
|
|
78
|
-
'--hot',
|
|
79
|
-
'run',
|
|
80
|
-
'--preload',
|
|
81
|
-
'./eco.config.ts',
|
|
82
|
-
'app.ts',
|
|
83
|
-
'--dev',
|
|
84
|
-
]);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('buildNodeArgs imports eco.config.ts when present', () => {
|
|
88
|
-
expect(buildNodeArgs(['--dev'], {}, 'app.ts', true)).toEqual([
|
|
89
|
-
'--import',
|
|
90
|
-
'./eco.config.ts',
|
|
91
|
-
'app.ts',
|
|
92
|
-
'--dev',
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('resolveTsxCliPath resolves the packaged tsx cli entry', () => {
|
|
97
|
-
expect(resolveTsxCliPath()).toBe(require.resolve('tsx/cli'));
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
it('createLaunchPlan uses the packaged tsx cli for node runtime', async () => {
|
|
101
|
-
const tempDir = fs.mkdtempSync(path.join(tmpdir(), 'eco-cli-launch-plan-'));
|
|
102
|
-
try {
|
|
103
|
-
process.env.npm_config_user_agent = 'pnpm/10.0.0 npm/? node/v24.0.0 darwin arm64';
|
|
104
|
-
process.chdir(tempDir);
|
|
105
|
-
fs.writeFileSync(path.join(tempDir, 'app.ts'), 'await Promise.resolve();', 'utf8');
|
|
106
|
-
writeExperimentalRuntimeConfig(tempDir);
|
|
107
|
-
|
|
108
|
-
const plan = await createLaunchPlan(['--dev'], { runtime: 'node', nodeEnv: 'development' }, 'app.ts');
|
|
109
|
-
|
|
110
|
-
expect(plan).toMatchObject({
|
|
111
|
-
runtime: 'node',
|
|
112
|
-
executionStrategy: 'direct-runtime',
|
|
113
|
-
command: process.execPath,
|
|
114
|
-
});
|
|
115
|
-
expect(plan.commandArgs).toEqual([
|
|
116
|
-
require.resolve('tsx/cli'),
|
|
117
|
-
'--import',
|
|
118
|
-
'./eco.config.ts',
|
|
119
|
-
'app.ts',
|
|
120
|
-
'--dev',
|
|
121
|
-
]);
|
|
122
|
-
} finally {
|
|
123
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it('createLaunchPlan uses bun direct runtime and preloads eco.config.ts', async () => {
|
|
128
|
-
const tempDir = fs.mkdtempSync(path.join(tmpdir(), 'eco-cli-launch-plan-'));
|
|
129
|
-
try {
|
|
130
|
-
process.chdir(tempDir);
|
|
131
|
-
fs.writeFileSync(path.join(tempDir, 'app.ts'), 'await Promise.resolve();', 'utf8');
|
|
132
|
-
writeExperimentalRuntimeConfig(tempDir);
|
|
133
|
-
|
|
134
|
-
const plan = await createLaunchPlan(['--preview'], { runtime: 'bun' }, 'app.ts');
|
|
135
|
-
|
|
136
|
-
expect(plan).toMatchObject({
|
|
137
|
-
runtime: 'bun',
|
|
138
|
-
executionStrategy: 'direct-runtime',
|
|
139
|
-
command: 'bun',
|
|
140
|
-
});
|
|
141
|
-
expect(plan.commandArgs).toEqual(['run', '--preload', './eco.config.ts', 'app.ts', '--preview']);
|
|
142
|
-
} finally {
|
|
143
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
144
|
-
}
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it('launchPlanRequiresExistingEntryFile requires a concrete entry on every runtime path', async () => {
|
|
148
|
-
const tempDir = fs.mkdtempSync(path.join(tmpdir(), 'eco-cli-launch-plan-'));
|
|
149
|
-
try {
|
|
150
|
-
process.chdir(tempDir);
|
|
151
|
-
fs.writeFileSync(path.join(tempDir, 'app.ts'), 'await Promise.resolve();', 'utf8');
|
|
152
|
-
writeExperimentalRuntimeConfig(tempDir);
|
|
153
|
-
|
|
154
|
-
const bunPlan = await createLaunchPlan(['--dev'], { nodeEnv: 'development' }, 'app.ts');
|
|
155
|
-
expect(launchPlanRequiresExistingEntryFile(bunPlan)).toBe(true);
|
|
156
|
-
} finally {
|
|
157
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
});
|