feega 0.1.30 → 0.1.31

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/feega.mjs CHANGED
@@ -56,6 +56,7 @@ async function chooseVersion(home) {
56
56
  }
57
57
 
58
58
  async function install(dir, version) {
59
+ console.log(eventLine({ event: 'step', step: 'download' }));
59
60
  console.error(`feega: downloading the app ${version} (once per version)…`);
60
61
  rmSync(dir, { recursive: true, force: true });
61
62
  mkdirSync(dir, { recursive: true });
@@ -66,6 +67,7 @@ async function install(dir, version) {
66
67
  throw new Error('could not extract the app bundle');
67
68
  }
68
69
 
70
+ console.log(eventLine({ event: 'step', step: 'install' }));
69
71
  console.error('feega: installing its dependencies for this machine…');
70
72
  const deps = spawnSync('npm', ['ci', '--omit=dev', '--no-audit', '--no-fund', '--loglevel=error'], {
71
73
  cwd: dir,
@@ -102,6 +104,10 @@ async function readyApp() {
102
104
 
103
105
  async function wantsImport(app, file, mode) {
104
106
  const step = importStep({ mode, app, fileExists: existsSync(file), tty: Boolean(process.stdin.isTTY && process.stdout.isTTY) });
107
+ if (step === ImportStep.NoApp) {
108
+ throw new Error(`nothing to import: ${process.cwd()} has no package.json with a "dev" script`);
109
+ }
110
+
105
111
  if (step !== ImportStep.Ask) {
106
112
  return step === ImportStep.Import;
107
113
  }
@@ -155,6 +161,7 @@ async function importFolder(url, folder, { routes, app, file }) {
155
161
  throw new Error('could not find the local canvas');
156
162
  }
157
163
 
164
+ console.log(eventLine({ event: 'step', step: 'find', state: 'active' }));
158
165
  console.log(`feega: looking for the pages of ${basename(folder)}…`);
159
166
  const discovered = await discover(url, place, folder, app);
160
167
  const plan = routePlan(discovered.found, routes);
@@ -162,6 +169,7 @@ async function importFolder(url, folder, { routes, app, file }) {
162
169
  console.log('feega: no router found, importing the home page only');
163
170
  }
164
171
 
172
+ console.log(eventLine({ event: 'step', step: 'find', state: 'done', pages: plan.routes.length }));
165
173
  console.log(`feega: importing ${basename(folder)}: ${plan.routes.length} pages (starts its dev server, can take a minute)…`);
166
174
  const { path, body } = importAsk(place, folder, { routes: plan.routes, app: discovered.app });
167
175
  const { res, body: done } = await fetchJson(url, path, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });
@@ -225,6 +233,7 @@ async function main() {
225
233
  const port = await freePort(args.port);
226
234
 
227
235
  const url = boundUrl(port);
236
+ console.log(eventLine({ event: 'step', step: 'start' }));
228
237
  console.log(`feega: saving to ${file}`);
229
238
  console.log(`feega: open ${url}`);
230
239
 
@@ -239,7 +248,10 @@ async function main() {
239
248
  }
240
249
 
241
250
  if (importing) {
242
- await importFolder(url, app, { routes, app: chosenApp, file }).catch((error) => console.error(`feega: ${error.message}`));
251
+ await importFolder(url, app, { routes, app: chosenApp, file }).catch((error) => {
252
+ console.error(`feega: ${error.message}`);
253
+ console.log(eventLine({ event: 'import-failed', message: error.message }));
254
+ });
243
255
  }
244
256
  }
245
257
 
package/launcher.mjs CHANGED
@@ -10,7 +10,7 @@ export const MCP_ENTRY = 'mcp.mjs';
10
10
  export const USAGE = `usage: feega [file.feega] [--port <n>] [--no-open] [--import | --no-import] [--routes <list|all>] [--app <path>] [--help] [--version]
11
11
  feega mcp [--port <n>] MCP server (stdio) for the local feega on that port (default ${MCP_PORT})`;
12
12
  export const FolderImport = { Ask: 'ask', Yes: 'yes', No: 'no' };
13
- export const ImportStep = { Ask: 'ask', Import: 'import', Skip: 'skip' };
13
+ export const ImportStep = { Ask: 'ask', Import: 'import', Skip: 'skip', NoApp: 'no-app' };
14
14
 
15
15
  const IMPORT_FLAGS = { '--import': FolderImport.Yes, '--no-import': FolderImport.No };
16
16
  const HOME_ROUTE = '/';
@@ -218,7 +218,7 @@ const STEPS = {
218
218
 
219
219
  export function importStep({ mode, app, fileExists, tty }) {
220
220
  if (!app) {
221
- return ImportStep.Skip;
221
+ return mode === FolderImport.Yes ? ImportStep.NoApp : ImportStep.Skip;
222
222
  }
223
223
 
224
224
  return STEPS[mode]({ fileExists, tty });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "feega",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "Run feega's infinite canvas locally, saved to a .feega file. No account, no database.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",