zitejs 0.10.1 → 0.10.2

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.
@@ -64,15 +64,32 @@ const writeIfChanged = (appDir, file, content) => {
64
64
  return true;
65
65
  };
66
66
  exports.writeIfChanged = writeIfChanged;
67
- const isStartAppDir = (appPath) => {
67
+ const readConfig = (dir) => {
68
68
  try {
69
- return (JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(appPath, 'zite.config.json'), 'utf-8'))
70
- ?.runtime === 'start');
69
+ return (JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(dir, 'zite.config.json'), 'utf-8')) ??
70
+ undefined);
71
71
  }
72
72
  catch {
73
- return false;
73
+ return undefined;
74
+ }
75
+ };
76
+ // The workspace root is the config that names the project, and its runtime is
77
+ // every app's.
78
+ const workspaceRuntime = (dir) => {
79
+ for (let at = (0, node_path_1.resolve)(dir);; at = (0, node_path_1.dirname)(at)) {
80
+ const config = readConfig(at);
81
+ if (config?.project !== undefined)
82
+ return config.runtime;
83
+ if ((0, node_path_1.dirname)(at) === at)
84
+ return undefined;
74
85
  }
75
86
  };
87
+ const isStartAppDir = (appPath) => {
88
+ const own = readConfig(appPath);
89
+ if (!own || own.project !== undefined)
90
+ return false;
91
+ return own.runtime === 'start' || workspaceRuntime(appPath) === 'start';
92
+ };
76
93
  exports.isStartAppDir = isStartAppDir;
77
94
  const isStartApp = (app) => (0, exports.isStartAppDir)(app.path);
78
95
  const workspaceHasStartApps = () => (0, sourceRoots_js_1.listSourceDirs)().some(isStartApp);
@@ -1,5 +1,5 @@
1
1
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs';
2
- import { dirname, join, relative } from 'node:path';
2
+ import { dirname, join, relative, resolve } from 'node:path';
3
3
  import { listSourceDirs } from '../../sourceRoots.js';
4
4
  import { renderRoleIds, START_ROLES_FILE, workspaceRoleIds, } from './roleIds.js';
5
5
  export const START_SERVER_ENTRY = '.zite/server.ts';
@@ -54,15 +54,32 @@ export const writeIfChanged = (appDir, file, content) => {
54
54
  writeFileSync(target, content);
55
55
  return true;
56
56
  };
57
- export const isStartAppDir = (appPath) => {
57
+ const readConfig = (dir) => {
58
58
  try {
59
- return (JSON.parse(readFileSync(join(appPath, 'zite.config.json'), 'utf-8'))
60
- ?.runtime === 'start');
59
+ return (JSON.parse(readFileSync(join(dir, 'zite.config.json'), 'utf-8')) ??
60
+ undefined);
61
61
  }
62
62
  catch {
63
- return false;
63
+ return undefined;
64
+ }
65
+ };
66
+ // The workspace root is the config that names the project, and its runtime is
67
+ // every app's.
68
+ const workspaceRuntime = (dir) => {
69
+ for (let at = resolve(dir);; at = dirname(at)) {
70
+ const config = readConfig(at);
71
+ if (config?.project !== undefined)
72
+ return config.runtime;
73
+ if (dirname(at) === at)
74
+ return undefined;
64
75
  }
65
76
  };
77
+ export const isStartAppDir = (appPath) => {
78
+ const own = readConfig(appPath);
79
+ if (!own || own.project !== undefined)
80
+ return false;
81
+ return own.runtime === 'start' || workspaceRuntime(appPath) === 'start';
82
+ };
66
83
  const isStartApp = (app) => isStartAppDir(app.path);
67
84
  export const workspaceHasStartApps = () => listSourceDirs().some(isStartApp);
68
85
  /**
@@ -1 +1 @@
1
- export declare const ZITEJS_VERSION = "0.10.1";
1
+ export declare const ZITEJS_VERSION = "0.10.2";
@@ -1,2 +1,2 @@
1
1
  // Written by scripts/write-version.mjs from package.json.
2
- export const ZITEJS_VERSION = '0.10.1';
2
+ export const ZITEJS_VERSION = '0.10.2';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zitejs",
3
- "version": "0.10.1",
3
+ "version": "0.10.2",
4
4
  "description": "The Zite framework — build apps on Zite Database",
5
5
  "type": "module",
6
6
  "sideEffects": [