@celljs/cli 4.1.0 → 4.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.
Files changed (97) hide show
  1. package/README.md +3 -3
  2. package/agent/guide.md +5 -3
  3. package/lib/agent/agent-guide.d.ts.map +1 -1
  4. package/lib/agent/agent-guide.js +3 -2
  5. package/lib/agent/agent-guide.js.map +1 -1
  6. package/lib/build/single-compile.spec.js +15 -9
  7. package/lib/build/single-compile.spec.js.map +1 -1
  8. package/lib/check/project-checker.d.ts +15 -9
  9. package/lib/check/project-checker.d.ts.map +1 -1
  10. package/lib/check/project-checker.js +23 -34
  11. package/lib/check/project-checker.js.map +1 -1
  12. package/lib/check/project-checker.spec.js +16 -5
  13. package/lib/check/project-checker.spec.js.map +1 -1
  14. package/lib/cli/cell-cli.spec.js +9 -4
  15. package/lib/cli/cell-cli.spec.js.map +1 -1
  16. package/lib/cli/check-command.d.ts.map +1 -1
  17. package/lib/cli/check-command.js +2 -2
  18. package/lib/cli/check-command.js.map +1 -1
  19. package/lib/cli/dev-command.spec.js +8 -3
  20. package/lib/cli/dev-command.spec.js.map +1 -1
  21. package/lib/config/config-explainer.d.ts.map +1 -1
  22. package/lib/config/config-explainer.js +2 -2
  23. package/lib/config/config-explainer.js.map +1 -1
  24. package/lib/deploy/code-package.d.ts +3 -2
  25. package/lib/deploy/code-package.d.ts.map +1 -1
  26. package/lib/deploy/code-package.js +3 -3
  27. package/lib/deploy/code-package.js.map +1 -1
  28. package/lib/deploy/deploy-utils.spec.js +16 -1
  29. package/lib/deploy/deploy-utils.spec.js.map +1 -1
  30. package/lib/deploy/zip-writer.d.ts +6 -2
  31. package/lib/deploy/zip-writer.d.ts.map +1 -1
  32. package/lib/deploy/zip-writer.js +9 -3
  33. package/lib/deploy/zip-writer.js.map +1 -1
  34. package/lib/docs/docs-index.d.ts.map +1 -1
  35. package/lib/docs/docs-index.js +3 -2
  36. package/lib/docs/docs-index.js.map +1 -1
  37. package/lib/events/hook-runner.spec.js +9 -4
  38. package/lib/events/hook-runner.spec.js.map +1 -1
  39. package/lib/info/project-inspector.d.ts.map +1 -1
  40. package/lib/info/project-inspector.js +4 -3
  41. package/lib/info/project-inspector.js.map +1 -1
  42. package/lib/init/project-initializer.d.ts.map +1 -1
  43. package/lib/init/project-initializer.js +2 -1
  44. package/lib/init/project-initializer.js.map +1 -1
  45. package/lib/mcp/dev-mcp-endpoint.d.ts +7 -14
  46. package/lib/mcp/dev-mcp-endpoint.d.ts.map +1 -1
  47. package/lib/mcp/dev-mcp-endpoint.js +4 -13
  48. package/lib/mcp/dev-mcp-endpoint.js.map +1 -1
  49. package/lib/mcp/dev-mcp-endpoint.spec.js +7 -7
  50. package/lib/mcp/dev-mcp-endpoint.spec.js.map +1 -1
  51. package/lib/preset/cloudflare/cloudflare-deployer.d.ts.map +1 -1
  52. package/lib/preset/cloudflare/cloudflare-deployer.js +3 -2
  53. package/lib/preset/cloudflare/cloudflare-deployer.js.map +1 -1
  54. package/lib/preset/cloudflare/wrangler-config.d.ts.map +1 -1
  55. package/lib/preset/cloudflare/wrangler-config.js +2 -1
  56. package/lib/preset/cloudflare/wrangler-config.js.map +1 -1
  57. package/lib/preset/fc/fc-deployer.js +2 -2
  58. package/lib/preset/fc/fc-deployer.js.map +1 -1
  59. package/lib/preset/lambda/lambda-deployer.js +2 -2
  60. package/lib/preset/lambda/lambda-deployer.js.map +1 -1
  61. package/lib/preset/preset-output.d.ts.map +1 -1
  62. package/lib/preset/preset-output.js +9 -1
  63. package/lib/preset/preset-output.js.map +1 -1
  64. package/lib/preset/scf/scf-deployer.js +2 -2
  65. package/lib/preset/scf/scf-deployer.js.map +1 -1
  66. package/lib/preset/serverless-presets.spec.js +19 -3
  67. package/lib/preset/serverless-presets.spec.js.map +1 -1
  68. package/lib/test/fixture-project.d.ts.map +1 -1
  69. package/lib/test/fixture-project.js +2 -1
  70. package/lib/test/fixture-project.js.map +1 -1
  71. package/lib/utils/path-util.d.ts +5 -0
  72. package/lib/utils/path-util.d.ts.map +1 -0
  73. package/lib/utils/path-util.js +10 -0
  74. package/lib/utils/path-util.js.map +1 -0
  75. package/lib/utils/path-util.spec.d.ts +2 -0
  76. package/lib/utils/path-util.spec.d.ts.map +1 -0
  77. package/lib/utils/path-util.spec.js +11 -0
  78. package/lib/utils/path-util.spec.js.map +1 -0
  79. package/package.json +9 -9
  80. package/src/agent/agent-guide.ts +3 -2
  81. package/src/check/project-checker.ts +36 -40
  82. package/src/cli/check-command.ts +2 -2
  83. package/src/config/config-explainer.ts +2 -2
  84. package/src/deploy/code-package.ts +4 -4
  85. package/src/deploy/zip-writer.ts +9 -3
  86. package/src/docs/docs-index.ts +3 -2
  87. package/src/info/project-inspector.ts +4 -3
  88. package/src/init/project-initializer.ts +2 -1
  89. package/src/mcp/dev-mcp-endpoint.ts +10 -19
  90. package/src/preset/cloudflare/cloudflare-deployer.ts +3 -2
  91. package/src/preset/cloudflare/wrangler-config.ts +2 -1
  92. package/src/preset/fc/fc-deployer.ts +2 -2
  93. package/src/preset/lambda/lambda-deployer.ts +2 -2
  94. package/src/preset/preset-output.ts +9 -1
  95. package/src/preset/scf/scf-deployer.ts +2 -2
  96. package/src/test/fixture-project.ts +2 -1
  97. package/src/utils/path-util.ts +8 -0
@@ -4,18 +4,18 @@ import type { CellDevServer } from '@celljs/vite';
4
4
  import { DevActivity, type LogLevel } from './dev-activity.js';
5
5
  import { McpServer } from './mcp-server.js';
6
6
 
7
- /** The parts of an inversify 6 container the endpoint reads. */
7
+ /** The parts of the @celljs/core container the endpoint reads. */
8
8
  interface ContainerLike {
9
9
  get(id: unknown): unknown;
10
- parent?: ContainerLike | null;
11
- _bindingDictionary?: { getMap(): Map<unknown, BindingLike[]> };
10
+ bindings(): ReadonlyMap<unknown, readonly BindingLike[]>;
12
11
  }
13
12
 
14
13
  interface BindingLike {
15
14
  type?: string;
16
15
  scope?: string;
17
- implementationType?: { name?: string } | null;
18
- constraint?: { metaData?: { key?: unknown; value?: unknown } };
16
+ implementation?: { name?: string };
17
+ /** `named x`, `tagged k=v`, `default`. */
18
+ condition?: string;
19
19
  }
20
20
 
21
21
  interface RouteLike {
@@ -224,16 +224,9 @@ export class DevMcpEndpoint {
224
224
  return container;
225
225
  }
226
226
 
227
- /** Every binding of the container and its parents, by identifier. */
228
- protected static entries(container: ContainerLike): [unknown, BindingLike[]][] {
229
- const entries: [unknown, BindingLike[]][] = [];
230
- for (let c: ContainerLike | null | undefined = container; c; c = c.parent) {
231
- const map = c._bindingDictionary?.getMap();
232
- if (map) {
233
- entries.push(...map.entries());
234
- }
235
- }
236
- return entries;
227
+ /** Every binding of the container, by identifier. */
228
+ protected static entries(container: ContainerLike): [unknown, readonly BindingLike[]][] {
229
+ return [...container.bindings().entries()];
237
230
  }
238
231
 
239
232
  static idName(id: unknown): string {
@@ -258,12 +251,10 @@ export class DevMcpEndpoint {
258
251
  const rows = DevMcpEndpoint.entries(this.container()).flatMap(([id, bindings]) =>
259
252
  bindings.map(binding => ({
260
253
  id: DevMcpEndpoint.idName(id),
261
- ...(binding.implementationType?.name ? { implementation: binding.implementationType.name } : {}),
254
+ ...(binding.implementation?.name ? { implementation: binding.implementation.name } : {}),
262
255
  type: binding.type,
263
256
  scope: binding.scope,
264
- ...(binding.constraint?.metaData?.key !== undefined
265
- ? { constraint: `${String(binding.constraint.metaData.key)}=${String(binding.constraint.metaData.value)}` }
266
- : {}),
257
+ ...(binding.condition ? { constraint: binding.condition } : {}),
267
258
  })),
268
259
  );
269
260
  const matching = needle ? rows.filter(r => r.id.toLowerCase().includes(needle) || r.implementation?.toLowerCase().includes(needle)) : rows;
@@ -1,7 +1,8 @@
1
1
  import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
2
2
  import { tmpdir } from 'node:os';
3
- import { join, relative } from 'node:path';
3
+ import { join } from 'node:path';
4
4
  import { CellError, type DeployContext, type Deployment, type DeployPlan, type DeployResource, defineDeployer } from '@celljs/kit';
5
+ import { PathUtil } from '../../utils/path-util.js';
5
6
  import { Wrangler } from './wrangler.js';
6
7
  import { WranglerConfig, type WranglerJson } from './wrangler-config.js';
7
8
 
@@ -37,7 +38,7 @@ export class CloudflareDeployment {
37
38
  deployer: 'cloudflare',
38
39
  resources: this.resources(config, result.output),
39
40
  details: {
40
- config: relative(this.context.root, this.file),
41
+ config: PathUtil.relative(this.context.root, this.file),
41
42
  wrangler: result.source === 'project' ? 'project' : Wrangler.PACKAGE,
42
43
  credentials: this.context.env.CLOUDFLARE_API_TOKEN ? 'CLOUDFLARE_API_TOKEN' : 'wrangler login',
43
44
  },
@@ -3,6 +3,7 @@ import { basename, join, relative, resolve } from 'node:path';
3
3
  import { CellError, type OutputManifest } from '@celljs/kit';
4
4
  import { ConfigUtil } from '@celljs/vite';
5
5
  import { JsonUtil } from '../../utils/json-util.js';
6
+ import { PathUtil } from '../../utils/path-util.js';
6
7
 
7
8
  export type WranglerJson = Record<string, unknown>;
8
9
 
@@ -166,7 +167,7 @@ export class WranglerConfig {
166
167
  return { not_found_handling: 'single-page-application', ...assets, directory: manifest.public };
167
168
  }
168
169
  if (typeof assets?.directory === 'string') {
169
- return { ...assets, directory: relative(outDir, resolve(this.root, assets.directory)) || '.' };
170
+ return { ...assets, directory: PathUtil.relative(outDir, resolve(this.root, assets.directory)) || '.' };
170
171
  }
171
172
  return assets;
172
173
  }
@@ -115,7 +115,7 @@ export class FcDeployment {
115
115
 
116
116
  async plan(): Promise<DeployPlan> {
117
117
  this.checkOutput();
118
- const code = CodePackage.of(this.context.outDir);
118
+ const code = CodePackage.of(this.context.outDir, this.context.manifest);
119
119
  let exists: { fn?: boolean; trigger?: boolean } = {};
120
120
  if (this.credentials) {
121
121
  const client = new FcClient(this.region, this.credentials, this.io);
@@ -165,7 +165,7 @@ export class FcDeployment {
165
165
  throw CloudCredentials.missing('Alibaba Cloud', FcDeployment.CREDENTIALS, ' (an AccessKey of a RAM user with AliyunFCFullAccess)');
166
166
  }
167
167
  const client = new FcClient(this.region, this.credentials, this.io);
168
- const code = CodePackage.of(this.context.outDir);
168
+ const code = CodePackage.of(this.context.outDir, this.context.manifest);
169
169
  code.checkSize(FcDeployment.MAX_PACKAGE, 'Function Compute', 'Keep large packages out of the server bundle (build.external) and the output directory.');
170
170
  const config = this.functionConfig(code);
171
171
  const path = `/${FcClient.VERSION}/functions/${this.name}`;
@@ -111,7 +111,7 @@ export class LambdaDeployment {
111
111
 
112
112
  async plan(): Promise<DeployPlan> {
113
113
  this.checkOutput();
114
- const code = CodePackage.of(this.context.outDir);
114
+ const code = CodePackage.of(this.context.outDir, this.context.manifest);
115
115
  let fn: boolean | undefined;
116
116
  let url: boolean | undefined;
117
117
  if (this.credentials) {
@@ -151,7 +151,7 @@ export class LambdaDeployment {
151
151
  throw CloudCredentials.missing('AWS', LambdaDeployment.CREDENTIALS, ', or a profile in ~/.aws/credentials (AWS_PROFILE)');
152
152
  }
153
153
  const client = new AwsClient(this.region, this.credentials, this.io);
154
- const code = CodePackage.of(this.context.outDir);
154
+ const code = CodePackage.of(this.context.outDir, this.context.manifest);
155
155
  code.checkSize(LambdaDeployment.MAX_PACKAGE, 'Lambda', 'Keep large packages out of the server bundle and the output directory.');
156
156
  const path = `/2015-03-31/functions/${this.name}`;
157
157
  if (await this.optional(() => client.lambda('GET', path), 'GetFunction')) {
@@ -32,6 +32,7 @@ export namespace PresetOutput {
32
32
  return manifest;
33
33
  }
34
34
  const files = new Set(manifest.files ?? []);
35
+ const executables = new Set(manifest.executables ?? []);
35
36
  await preset.output({
36
37
  ...options,
37
38
  options: options.options ?? {},
@@ -40,15 +41,22 @@ export namespace PresetOutput {
40
41
  const file = join(options.outDir, path);
41
42
  mkdirSync(dirname(file), { recursive: true });
42
43
  writeFileSync(file, content);
44
+ const name = path.replace(/\\/g, '/');
43
45
  if (mode !== undefined) {
44
46
  chmodSync(file, mode);
47
+ if (mode & 0o111) {
48
+ executables.add(name);
49
+ }
45
50
  }
46
- files.add(path.replace(/\\/g, '/'));
51
+ files.add(name);
47
52
  },
48
53
  });
49
54
  if (files.size > 0) {
50
55
  manifest.files = [...files].sort();
51
56
  }
57
+ if (executables.size > 0) {
58
+ manifest.executables = [...executables].sort();
59
+ }
52
60
  writeFileSync(join(options.outDir, MANIFEST), `${JSON.stringify(manifest, null, 2)}\n`);
53
61
  return manifest;
54
62
  }
@@ -89,7 +89,7 @@ export class ScfDeployment {
89
89
 
90
90
  async plan(): Promise<DeployPlan> {
91
91
  this.checkOutput();
92
- const code = CodePackage.of(this.context.outDir);
92
+ const code = CodePackage.of(this.context.outDir, this.context.manifest);
93
93
  let fn: boolean | undefined;
94
94
  let url: boolean | undefined;
95
95
  if (this.credentials) {
@@ -130,7 +130,7 @@ export class ScfDeployment {
130
130
  throw CloudCredentials.missing('Tencent Cloud', ScfDeployment.CREDENTIALS, ' (an API key of a sub-user with QcloudSCFFullAccess)');
131
131
  }
132
132
  const client = new ScfClient(this.region, this.credentials, this.io);
133
- const code = CodePackage.of(this.context.outDir);
133
+ const code = CodePackage.of(this.context.outDir, this.context.manifest);
134
134
  code.checkSize(
135
135
  ScfDeployment.MAX_PACKAGE,
136
136
  'SCF',
@@ -45,6 +45,7 @@ export class FixtureProject {
45
45
  }
46
46
 
47
47
  dispose(): void {
48
- rmSync(this.root, { recursive: true, force: true });
48
+ // Windows keeps the files of a process that was just killed busy for a moment.
49
+ rmSync(this.root, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
49
50
  }
50
51
  }
@@ -0,0 +1,8 @@
1
+ import { relative as nativeRelative, sep } from 'node:path';
2
+
3
+ export namespace PathUtil {
4
+ /** `path.relative` with `/` on every platform: paths in JSON and compiler-style output read the same on Windows. */
5
+ export function relative(from: string, to: string): string {
6
+ return nativeRelative(from, to).split(sep).join('/');
7
+ }
8
+ }