@treeseed/sdk 0.4.4 → 0.4.6
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/dist/fixture-support.d.ts +1 -1
- package/dist/fixture-support.js +5 -5
- package/dist/operations/services/config-runtime.js +1 -1
- package/dist/operations/services/railway-deploy.js +1 -1
- package/dist/operations/services/runtime-tools.d.ts +1 -1
- package/dist/operations/services/runtime-tools.js +39 -5
- package/dist/scripts/test-scaffold.js +5 -21
- package/dist/scripts/treeseed-release-verify.js +3 -3
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ export type FixtureSupportDeclaration = {
|
|
|
4
4
|
modes: readonly FixtureInjectionMode[];
|
|
5
5
|
workspaceDirName?: string;
|
|
6
6
|
entrySpecifier?: string;
|
|
7
|
-
contractsShim?: 'agent';
|
|
7
|
+
contractsShim?: 'core-agent';
|
|
8
8
|
};
|
|
9
9
|
export type ResolveSharedFixtureOptions = {
|
|
10
10
|
packageRoot?: string;
|
package/dist/fixture-support.js
CHANGED
|
@@ -106,15 +106,15 @@ function ensureFixtureLinkedPackage(fixtureRoot, packageName, resolvedPackageRoo
|
|
|
106
106
|
rmSync(packageDir, { recursive: true, force: true });
|
|
107
107
|
symlinkSync(resolvedPackageRoot, packageDir, "dir");
|
|
108
108
|
}
|
|
109
|
-
function
|
|
110
|
-
const packageDir = resolve(fixtureRoot, "node_modules", "@treeseed", "
|
|
109
|
+
function buildCoreAgentContractsShimPackage(fixtureRoot) {
|
|
110
|
+
const packageDir = resolve(fixtureRoot, "node_modules", "@treeseed", "core");
|
|
111
111
|
rmSync(packageDir, { recursive: true, force: true });
|
|
112
112
|
mkdirSync(resolve(packageDir, "contracts"), { recursive: true });
|
|
113
113
|
writeFileSync(
|
|
114
114
|
resolve(packageDir, "package.json"),
|
|
115
115
|
JSON.stringify(
|
|
116
116
|
{
|
|
117
|
-
name: "@treeseed/
|
|
117
|
+
name: "@treeseed/core",
|
|
118
118
|
type: "module",
|
|
119
119
|
exports: {
|
|
120
120
|
"./runtime-types": {
|
|
@@ -315,8 +315,8 @@ function prepareFixturePackages(options) {
|
|
|
315
315
|
satisfied = true;
|
|
316
316
|
break;
|
|
317
317
|
}
|
|
318
|
-
if (mode === "contracts-only" && declaration.contractsShim === "agent") {
|
|
319
|
-
|
|
318
|
+
if (mode === "contracts-only" && declaration.contractsShim === "core-agent") {
|
|
319
|
+
buildCoreAgentContractsShimPackage(options.fixtureRoot);
|
|
320
320
|
satisfied = true;
|
|
321
321
|
break;
|
|
322
322
|
}
|
|
@@ -1064,7 +1064,7 @@ function syncTreeseedRailwayEnvironment({ tenantRoot, scope = "prod", dryRun = f
|
|
|
1064
1064
|
}
|
|
1065
1065
|
const environment = service.environments?.[scope];
|
|
1066
1066
|
const fallbackServiceName = serviceKey === "api" ? config.settings.services.railway.apiServiceName : serviceKey === "agents" ? config.settings.services.railway.agentsServiceName : "";
|
|
1067
|
-
const defaultRootDir =
|
|
1067
|
+
const defaultRootDir = ["api", "manager", "worker", "workdayStart", "workdayReport"].includes(serviceKey) ? "." : "packages/core";
|
|
1068
1068
|
return {
|
|
1069
1069
|
service: serviceKey,
|
|
1070
1070
|
projectName: service.railway?.projectName ?? config.settings.services.railway.projectName,
|
|
@@ -26,7 +26,7 @@ function configuredRailwayServices(tenantRoot, scope) {
|
|
|
26
26
|
if (!service || service.enabled === false || (service.provider ?? "railway") !== "railway") {
|
|
27
27
|
return null;
|
|
28
28
|
}
|
|
29
|
-
const defaultRootDir =
|
|
29
|
+
const defaultRootDir = ["api", "manager", "worker", "workdayStart", "workdayReport"].includes(serviceKey) ? "." : "packages/core";
|
|
30
30
|
const serviceRoot = resolve(tenantRoot, service.railway?.rootDir ?? service.rootDir ?? defaultRootDir);
|
|
31
31
|
const railwayEnvironment = service.environments?.[normalizedScope]?.railwayEnvironment ?? normalizedScope;
|
|
32
32
|
const publicBaseUrl = service.environments?.[normalizedScope]?.baseUrl ?? service.publicBaseUrl ?? null;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const packageRoot: string;
|
|
2
2
|
export declare const packageScriptRoot: string;
|
|
3
|
+
export declare const packageDistScriptRoot: string;
|
|
3
4
|
export declare const runtimeRoot: string;
|
|
4
5
|
export declare function treeseedWorkspacePackageCheckoutState(root?: string): {
|
|
5
6
|
mode: string;
|
|
@@ -18,7 +19,6 @@ export declare function resolveAstroBin(): string;
|
|
|
18
19
|
export declare function resolveWranglerBin(): string;
|
|
19
20
|
export declare const corePackageRoot: string;
|
|
20
21
|
export declare const sdkPackageRoot: string;
|
|
21
|
-
export declare const agentPackageRoot: string;
|
|
22
22
|
export declare function loadPackageJson(root?: string): any;
|
|
23
23
|
export declare function isWorkspaceRoot(root?: string): boolean;
|
|
24
24
|
export declare function createProductionBuildEnv(extraEnv?: {}): {
|
|
@@ -6,7 +6,27 @@ import { createRequire } from "node:module";
|
|
|
6
6
|
import { parse as parseYaml } from "yaml";
|
|
7
7
|
const require2 = createRequire(import.meta.url);
|
|
8
8
|
const scriptRoot = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
|
|
9
|
+
function resolveSdkPackageRoot(startDir) {
|
|
10
|
+
let currentDir = startDir;
|
|
11
|
+
while (true) {
|
|
12
|
+
const packageJsonPath = resolve(currentDir, "package.json");
|
|
13
|
+
if (existsSync(packageJsonPath)) {
|
|
14
|
+
try {
|
|
15
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
|
|
16
|
+
if (packageJson?.name === "@treeseed/sdk") {
|
|
17
|
+
return currentDir;
|
|
18
|
+
}
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const parentDir = dirname(currentDir);
|
|
23
|
+
if (parentDir === currentDir) {
|
|
24
|
+
return resolve(startDir, "..", "..", "..");
|
|
25
|
+
}
|
|
26
|
+
currentDir = parentDir;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const packageRootFromSource = resolveSdkPackageRoot(scriptRoot);
|
|
10
30
|
const treeseedRuntimeRoot = resolve(packageRootFromSource, "src", "treeseed");
|
|
11
31
|
const TREESEED_DEFAULT_PLUGIN_REFERENCES = [
|
|
12
32
|
{
|
|
@@ -31,7 +51,7 @@ const TREESEED_DEFAULT_PROVIDER_SELECTIONS = {
|
|
|
31
51
|
site: "default"
|
|
32
52
|
};
|
|
33
53
|
const TRESEED_MANAGED_SERVICE_KEYS = ["api", "agents", "gateway", "manager", "worker", "workdayStart", "workdayReport"];
|
|
34
|
-
const TRESEED_WORKSPACE_PACKAGE_DIRS = ["sdk", "core", "cli"
|
|
54
|
+
const TRESEED_WORKSPACE_PACKAGE_DIRS = ["sdk", "core", "cli"];
|
|
35
55
|
const CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER = "replace-with-cloudflare-account-id";
|
|
36
56
|
function parseServiceEnvironmentConfig(value) {
|
|
37
57
|
const record = optionalRecord(value, "service environment") ?? {};
|
|
@@ -87,6 +107,7 @@ function parseManagedServicesConfig(value) {
|
|
|
87
107
|
}
|
|
88
108
|
const packageRoot = packageRootFromSource;
|
|
89
109
|
const packageScriptRoot = resolve(packageRoot, "scripts");
|
|
110
|
+
const packageDistScriptRoot = resolve(packageRoot, "dist", "scripts");
|
|
90
111
|
const runtimeRoot = treeseedRuntimeRoot;
|
|
91
112
|
function resolvePackageBinary(packageName, binName = packageName) {
|
|
92
113
|
const packageJsonPath = require2.resolve(`${packageName}/package.json`);
|
|
@@ -157,7 +178,6 @@ function resolveWranglerBin() {
|
|
|
157
178
|
}
|
|
158
179
|
const corePackageRoot = resolveTreeseedPackageRoot("@treeseed/core", "@treeseed/core/config", "core");
|
|
159
180
|
const sdkPackageRoot = resolveTreeseedPackageRoot("@treeseed/sdk", "@treeseed/sdk", "sdk");
|
|
160
|
-
const agentPackageRoot = resolveTreeseedPackageRoot("@treeseed/agent", "@treeseed/agent", "agent");
|
|
161
181
|
function loadPackageJson(root = process.cwd()) {
|
|
162
182
|
const packageJsonPath = resolve(root, "package.json");
|
|
163
183
|
if (!existsSync(packageJsonPath)) {
|
|
@@ -182,7 +202,15 @@ function createProductionBuildEnv(extraEnv = {}) {
|
|
|
182
202
|
}
|
|
183
203
|
function packageScriptPath(scriptName) {
|
|
184
204
|
if (extname(scriptName)) {
|
|
185
|
-
|
|
205
|
+
const directScriptPath = resolve(packageScriptRoot, scriptName);
|
|
206
|
+
if (existsSync(directScriptPath)) {
|
|
207
|
+
return directScriptPath;
|
|
208
|
+
}
|
|
209
|
+
const distScriptPath = resolve(packageDistScriptRoot, scriptName.replace(/\.(ts|mjs)$/u, ".js"));
|
|
210
|
+
if (existsSync(distScriptPath)) {
|
|
211
|
+
return distScriptPath;
|
|
212
|
+
}
|
|
213
|
+
return directScriptPath;
|
|
186
214
|
}
|
|
187
215
|
for (const extension of [".js", ".ts", ".mjs"]) {
|
|
188
216
|
const candidate = resolve(packageScriptRoot, `${scriptName}${extension}`);
|
|
@@ -190,6 +218,12 @@ function packageScriptPath(scriptName) {
|
|
|
190
218
|
return candidate;
|
|
191
219
|
}
|
|
192
220
|
}
|
|
221
|
+
for (const extension of [".js", ".mjs"]) {
|
|
222
|
+
const candidate = resolve(packageDistScriptRoot, `${scriptName}${extension}`);
|
|
223
|
+
if (existsSync(candidate)) {
|
|
224
|
+
return candidate;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
193
227
|
throw new Error(`Unable to resolve package script "${scriptName}".`);
|
|
194
228
|
}
|
|
195
229
|
function withProcessCwd(cwd, action) {
|
|
@@ -337,12 +371,12 @@ function spawnNodeBinary(binPath, args, options = {}) {
|
|
|
337
371
|
});
|
|
338
372
|
}
|
|
339
373
|
export {
|
|
340
|
-
agentPackageRoot,
|
|
341
374
|
corePackageRoot,
|
|
342
375
|
createProductionBuildEnv,
|
|
343
376
|
isWorkspaceRoot,
|
|
344
377
|
loadCliDeployConfig,
|
|
345
378
|
loadPackageJson,
|
|
379
|
+
packageDistScriptRoot,
|
|
346
380
|
packageRoot,
|
|
347
381
|
packageScriptPath,
|
|
348
382
|
packageScriptRoot,
|
|
@@ -3,7 +3,7 @@ import { cpSync, existsSync, mkdirSync, mkdtempSync, readdirSync, readFileSync,
|
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { dirname, join, resolve } from 'node:path';
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
|
-
import {
|
|
6
|
+
import { corePackageRoot, packageRoot, packageScriptPath, sdkPackageRoot } from '../operations/services/runtime-tools.js';
|
|
7
7
|
import { listTemplateProducts, validateTemplateProduct } from '../operations/services/template-registry.js';
|
|
8
8
|
const npmCacheDir = process.env.TREESEED_SCAFFOLD_NPM_CACHE_DIR
|
|
9
9
|
? resolve(process.env.TREESEED_SCAFFOLD_NPM_CACHE_DIR)
|
|
@@ -11,7 +11,6 @@ const npmCacheDir = process.env.TREESEED_SCAFFOLD_NPM_CACHE_DIR
|
|
|
11
11
|
const packageJson = JSON.parse(readFileSync(resolve(corePackageRoot, 'package.json'), 'utf8'));
|
|
12
12
|
const sdkPackageJson = JSON.parse(readFileSync(resolve(sdkPackageRoot, 'package.json'), 'utf8'));
|
|
13
13
|
const cliPackageJson = JSON.parse(readFileSync(resolve(packageRoot, 'package.json'), 'utf8'));
|
|
14
|
-
const agentPackageJson = JSON.parse(readFileSync(resolve(agentPackageRoot, 'package.json'), 'utf8'));
|
|
15
14
|
const workspaceTarballs = (() => {
|
|
16
15
|
try {
|
|
17
16
|
return JSON.parse(process.env.TREESEED_WORKSPACE_TARBALLS ?? '{}');
|
|
@@ -35,12 +34,7 @@ const externalCliTarball = process.env.TREESEED_SCAFFOLD_CLI_TARBALL
|
|
|
35
34
|
: typeof workspaceTarballs['@treeseed/cli'] === 'string'
|
|
36
35
|
? resolve(workspaceTarballs['@treeseed/cli'])
|
|
37
36
|
: null;
|
|
38
|
-
const
|
|
39
|
-
? resolve(process.env.TREESEED_SCAFFOLD_AGENT_TARBALL)
|
|
40
|
-
: typeof workspaceTarballs['@treeseed/agent'] === 'string'
|
|
41
|
-
? resolve(workspaceTarballs['@treeseed/agent'])
|
|
42
|
-
: null;
|
|
43
|
-
const reusesExternalTarballs = Boolean(externalCoreTarball || externalSdkTarball || externalCliTarball || externalAgentTarball);
|
|
37
|
+
const reusesExternalTarballs = Boolean(externalCoreTarball || externalSdkTarball || externalCliTarball);
|
|
44
38
|
const scaffoldChecks = new Set((process.env.TREESEED_SCAFFOLD_CHECKS ?? 'build,deploy')
|
|
45
39
|
.split(',')
|
|
46
40
|
.map((value) => value.trim())
|
|
@@ -177,7 +171,7 @@ function linkTreeseedBins(siteRoot) {
|
|
|
177
171
|
mkdirSync(binRoot, { recursive: true });
|
|
178
172
|
for (const [name, relativeTarget] of [
|
|
179
173
|
['treeseed', '../@treeseed/cli/dist/cli/main.js'],
|
|
180
|
-
['treeseed-agents', '../@treeseed/
|
|
174
|
+
['treeseed-agents', '../@treeseed/core/dist/agents/cli.js'],
|
|
181
175
|
]) {
|
|
182
176
|
symlinkSync(relativeTarget, resolve(binRoot, name));
|
|
183
177
|
}
|
|
@@ -210,12 +204,11 @@ async function scaffoldSite(siteRoot) {
|
|
|
210
204
|
}
|
|
211
205
|
runStep(process.execPath, [packageScriptPath('scaffold-site'), siteRoot, '--template', 'starter-basic', '--name', 'Smoke Site', '--site-url', 'https://smoke.example.com', '--contact-email', 'hello@example.com']);
|
|
212
206
|
}
|
|
213
|
-
function installScaffold(siteRoot, { coreTarballPath, sdkTarballPath, cliTarballPath
|
|
214
|
-
if (coreTarballPath && sdkTarballPath && cliTarballPath
|
|
207
|
+
function installScaffold(siteRoot, { coreTarballPath, sdkTarballPath, cliTarballPath }) {
|
|
208
|
+
if (coreTarballPath && sdkTarballPath && cliTarballPath) {
|
|
215
209
|
linkWorkspacePackage(siteRoot, sdkPackageJson.name, sdkPackageRoot);
|
|
216
210
|
linkWorkspacePackage(siteRoot, packageJson.name, corePackageRoot);
|
|
217
211
|
linkWorkspacePackage(siteRoot, cliPackageJson.name, packageRoot);
|
|
218
|
-
linkWorkspacePackage(siteRoot, agentPackageJson.name, agentPackageRoot);
|
|
219
212
|
mirrorSharedNodeModules(siteRoot);
|
|
220
213
|
linkTreeseedBins(siteRoot);
|
|
221
214
|
return;
|
|
@@ -247,7 +240,6 @@ const siteRoot = createTempSiteRoot();
|
|
|
247
240
|
let tarballPath = externalCoreTarball;
|
|
248
241
|
let sdkTarballPath = externalSdkTarball;
|
|
249
242
|
let cliTarballPath = externalCliTarball;
|
|
250
|
-
let agentTarballPath = externalAgentTarball;
|
|
251
243
|
try {
|
|
252
244
|
if (!reusesExternalTarballs && resetScaffoldCache) {
|
|
253
245
|
logStep(`resetting npm cache at ${npmCacheDir}`);
|
|
@@ -267,13 +259,6 @@ try {
|
|
|
267
259
|
else {
|
|
268
260
|
logStep(`reusing provided @treeseed/core tarball: ${tarballPath}`);
|
|
269
261
|
}
|
|
270
|
-
if (!agentTarballPath) {
|
|
271
|
-
logStep('building and packing @treeseed/agent');
|
|
272
|
-
agentTarballPath = createTarball(agentPackageRoot, agentPackageJson);
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
logStep(`reusing provided @treeseed/agent tarball: ${agentTarballPath}`);
|
|
276
|
-
}
|
|
277
262
|
if (!cliTarballPath) {
|
|
278
263
|
logStep('building and packing @treeseed/cli');
|
|
279
264
|
cliTarballPath = createTarball(packageRoot, cliPackageJson);
|
|
@@ -292,7 +277,6 @@ try {
|
|
|
292
277
|
coreTarballPath: tarballPath,
|
|
293
278
|
sdkTarballPath,
|
|
294
279
|
cliTarballPath,
|
|
295
|
-
agentTarballPath,
|
|
296
280
|
});
|
|
297
281
|
});
|
|
298
282
|
logStep('running scaffold smoke checks');
|
|
@@ -3,7 +3,7 @@ import { mkdtempSync } from 'node:fs';
|
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { dirname, extname, join, resolve } from 'node:path';
|
|
5
5
|
import { spawnSync } from 'node:child_process';
|
|
6
|
-
import {
|
|
6
|
+
import { corePackageRoot, packageRoot, sdkPackageRoot } from '../operations/services/runtime-tools.js';
|
|
7
7
|
const textExtensions = new Set(['.js', '.ts', '.mjs', '.cjs', '.d.js', '.json', '.md']);
|
|
8
8
|
const forbiddenPatterns = [
|
|
9
9
|
/['"`]workspace:[^'"`\n]+['"`]/,
|
|
@@ -108,11 +108,11 @@ function hasWorkspacePackageSource(root) {
|
|
|
108
108
|
run('npm', ['run', 'build']);
|
|
109
109
|
scanDirectory(resolve(packageRoot, 'dist'));
|
|
110
110
|
run('npm', ['test']);
|
|
111
|
-
if (hasWorkspacePackageSource(sdkPackageRoot) && hasWorkspacePackageSource(corePackageRoot)
|
|
111
|
+
if (hasWorkspacePackageSource(sdkPackageRoot) && hasWorkspacePackageSource(corePackageRoot)) {
|
|
112
112
|
run('npm', ['run', 'test:scaffold']);
|
|
113
113
|
}
|
|
114
114
|
else {
|
|
115
|
-
console.log('Skipping scaffold verification because local sdk/core
|
|
115
|
+
console.log('Skipping scaffold verification because local sdk/core package sources are not available.');
|
|
116
116
|
}
|
|
117
117
|
const stageRoot = mkdtempSync(join(tmpdir(), 'treeseed-cli-release-'));
|
|
118
118
|
const extractRoot = resolve(stageRoot, 'extract');
|