@xrystal/core 3.38.3 → 3.40.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 +397 -65
- package/package.json +2 -4
- package/x/bin/commands/create.mjs +2 -1
- package/x/bin/commands/doctor.mjs +5 -4
- package/x/bin/commands/hooks.mjs +2 -1
- package/x/bin/commands/project.mjs +2 -1
- package/x/bin/commands/release.mjs +3 -2
- package/x/bin/commands/sync.mjs +51 -0
- package/x/bin/commands/tmp.mjs +2 -1
- package/x/bin/helpers/.generated/tmp-schema.mjs +54 -85
- package/x/bin/helpers/banner.mjs +2 -2
- package/x/bin/helpers/build-config.mjs +11 -2
- package/x/bin/helpers/cli-help.mjs +9 -9
- package/x/bin/helpers/cli-identity.mjs +7 -17
- package/x/bin/helpers/defaults.json +14 -30
- package/x/bin/helpers/package-defaults.mjs +46 -12
- package/x/bin/helpers/project-artifacts.mjs +7 -0
- package/x/bin/helpers/seed-from-tmp.mjs +52 -0
- package/x/bin/helpers/toolchain-config.mjs +6 -12
- package/x/bin/main-cli.js +2 -2
- package/x/bin/scripts/install-git-hooks.mjs +3 -2
- package/x/bin/scripts/sync-cli-defaults.mjs +7 -2
- package/x/dist/project/index.js +1 -1
- package/x/dist/utils/constants/defaults.json +14 -30
- package/x/dist/utils/constants/index.d.ts +20 -12
- package/x/dist/utils/constants/index.js +1 -1
- package/x/dist/utils/helpers/tmp/index.d.ts +2 -0
- package/x/dist/utils/helpers/tmp/index.js +1 -1
- package/x/dist/utils/helpers/tmp/path-normalize.d.ts +10 -0
- package/x/dist/utils/helpers/tmp/path-normalize.js +1 -0
- package/x/dist/utils/helpers/tmp/seed-from-tmp.d.ts +9 -0
- package/x/dist/utils/helpers/tmp/seed-from-tmp.js +1 -0
- package/x/dist/utils/helpers/tmp/tmp-loader.js +1 -1
- package/x/dist/utils/helpers/tmp/tmp-schema.d.ts +1 -0
- package/x/dist/utils/helpers/tmp/tmp-schema.js +1 -1
- package/x/dist/utils/helpers/tmp/tmp-watch.js +1 -1
- package/x/bin/commands/sync-toolchain.mjs +0 -43
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CLI_PRIMARY_NAME } from './cli-identity.mjs'
|
|
1
2
|
import fs from 'node:fs'
|
|
2
3
|
import path from 'node:path'
|
|
3
4
|
|
|
@@ -32,7 +33,7 @@ export function resolveToolchainPaths(options = {}) {
|
|
|
32
33
|
outDir: `./${rootFolder}/${distSegment}`,
|
|
33
34
|
include: [mainFolder],
|
|
34
35
|
exclude: [`${rootFolder}/${testsSegment}`],
|
|
35
|
-
pathAliasKey: packageDefaults.
|
|
36
|
+
pathAliasKey: packageDefaults.pathAliasKey ?? '@/*',
|
|
36
37
|
pathAliasTarget: [`${mainFolder}/*`],
|
|
37
38
|
eslintFiles: [`${mainFolder}/**/*.ts`, `${mainFolder}/**/*.tsx`],
|
|
38
39
|
eslintIgnores: [
|
|
@@ -51,23 +52,16 @@ export function resolveToolchainPathsFromProject(root = process.cwd()) {
|
|
|
51
52
|
|
|
52
53
|
export function resolveRecommendedTsconfig(options = {}) {
|
|
53
54
|
const paths = resolveToolchainPaths(options)
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
// compilerOptions language lives in tsconfig.base.json (extends);
|
|
56
|
+
// sync only overlays layout fields from tmp.yml
|
|
56
57
|
return {
|
|
57
58
|
include: [...paths.include],
|
|
58
59
|
exclude: [...paths.exclude],
|
|
59
60
|
compilerOptions: {
|
|
60
|
-
target: 'ESNext',
|
|
61
|
-
module: 'ESNext',
|
|
62
|
-
moduleResolution: 'Bundler',
|
|
63
61
|
baseUrl: '.',
|
|
64
62
|
paths: { [paths.pathAliasKey]: paths.pathAliasTarget },
|
|
65
63
|
rootDir: paths.mainSourceFolder,
|
|
66
64
|
outDir: paths.outDir,
|
|
67
|
-
esModuleInterop: true,
|
|
68
|
-
forceConsistentCasingInFileNames: true,
|
|
69
|
-
skipLibCheck: true,
|
|
70
|
-
...baseOptions,
|
|
71
65
|
},
|
|
72
66
|
}
|
|
73
67
|
}
|
|
@@ -148,7 +142,7 @@ export function auditTsconfigAlignment(root, options = null) {
|
|
|
148
142
|
const recommended = resolveRecommendedTsconfig(resolvedOptions)
|
|
149
143
|
const onDisk = readProjectTsconfig(root)
|
|
150
144
|
if (!onDisk) {
|
|
151
|
-
return { ok: false, missing: true, notes: [
|
|
145
|
+
return { ok: false, missing: true, notes: [`tsconfig.json not found — run ${CLI_PRIMARY_NAME} sync`] }
|
|
152
146
|
}
|
|
153
147
|
|
|
154
148
|
const notes = []
|
|
@@ -175,7 +169,7 @@ export function auditTsconfigAlignment(root, options = null) {
|
|
|
175
169
|
|
|
176
170
|
export function createEslintConfigFromProject(root = process.cwd(), tseslint) {
|
|
177
171
|
const paths = resolveToolchainPathsFromProject(root)
|
|
178
|
-
const depth = packageDefaults.
|
|
172
|
+
const depth = packageDefaults.eslintRestrictedImportDepth ?? 2
|
|
179
173
|
const deepRelative = '../'.repeat(depth + 1)
|
|
180
174
|
|
|
181
175
|
return tseslint.config(
|
package/x/bin/main-cli.js
CHANGED
|
@@ -7,7 +7,7 @@ import { registerCreateCommand } from './commands/create.mjs'
|
|
|
7
7
|
import { registerDoctorCommand } from './commands/doctor.mjs'
|
|
8
8
|
import { registerProjectCommands } from './commands/project.mjs'
|
|
9
9
|
import { registerTmpCommand } from './commands/tmp.mjs'
|
|
10
|
-
import {
|
|
10
|
+
import { registerSyncCommand } from './commands/sync.mjs'
|
|
11
11
|
import { registerTagCommand, registerVersionCommand } from './commands/release.mjs'
|
|
12
12
|
import { registerHooksCommand } from './commands/hooks.mjs'
|
|
13
13
|
import { printBanner, shouldShowBanner } from './helpers/banner.mjs'
|
|
@@ -65,7 +65,7 @@ registerVersionCommand(cli, cliContext)
|
|
|
65
65
|
registerTagCommand(cli, cliContext)
|
|
66
66
|
registerDoctorCommand(cli, cliContext)
|
|
67
67
|
registerTmpCommand(cli, cliContext)
|
|
68
|
-
|
|
68
|
+
registerSyncCommand(cli, cliContext)
|
|
69
69
|
registerHooksCommand(cli, cliContext)
|
|
70
70
|
registerProjectCommands(cli, cliContext)
|
|
71
71
|
|
|
@@ -4,6 +4,7 @@ import path from 'node:path'
|
|
|
4
4
|
import { fileURLToPath } from 'node:url'
|
|
5
5
|
|
|
6
6
|
import { resolveProjectRoot } from '../helpers/project-root.mjs'
|
|
7
|
+
import { CLI_PRIMARY_NAME } from '../helpers/cli-identity.mjs'
|
|
7
8
|
|
|
8
9
|
const verifyScriptPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'verify-version-bump.mjs')
|
|
9
10
|
const HOOK_MARKER = '@xrystal/core version-bump pre-commit'
|
|
@@ -50,7 +51,7 @@ set -e
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
|
|
53
|
-
export function ensureHooksInstallScript(projectRoot, cliName =
|
|
54
|
+
export function ensureHooksInstallScript(projectRoot, cliName = CLI_PRIMARY_NAME) {
|
|
54
55
|
const packageJsonPath = path.join(projectRoot, 'package.json')
|
|
55
56
|
if (!fs.existsSync(packageJsonPath)) return false
|
|
56
57
|
|
|
@@ -66,7 +67,7 @@ export function ensureHooksInstallScript(projectRoot, cliName = 'xcore') {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/** Install pre-commit hook + package.json hooks:install script (create + manual). */
|
|
69
|
-
export function setupProjectGitHooks(projectRoot, { cliName =
|
|
70
|
+
export function setupProjectGitHooks(projectRoot, { cliName = CLI_PRIMARY_NAME } = {}) {
|
|
70
71
|
ensureHooksInstallScript(projectRoot, cliName)
|
|
71
72
|
const refreshed = isGitHookInstalled(projectRoot)
|
|
72
73
|
const result = installGitHooks(projectRoot)
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Publish artifact only.
|
|
4
|
+
* Authoring source of truth: source/utils/constants/defaults.json
|
|
5
|
+
* Local CLI prefers the authored file; npm pack needs this copy under x/bin.
|
|
6
|
+
*/
|
|
2
7
|
import fs from 'node:fs'
|
|
3
8
|
import path from 'node:path'
|
|
4
9
|
|
|
@@ -7,10 +12,10 @@ const src = path.join(root, 'source/utils/constants/defaults.json')
|
|
|
7
12
|
const dest = path.join(root, 'x/bin/helpers/defaults.json')
|
|
8
13
|
|
|
9
14
|
if (!fs.existsSync(src)) {
|
|
10
|
-
console.error('sync-cli-defaults: source
|
|
15
|
+
console.error('sync-cli-defaults: source/utils/constants/defaults.json missing')
|
|
11
16
|
process.exit(1)
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
fs.mkdirSync(path.dirname(dest), { recursive: true })
|
|
15
20
|
fs.copyFileSync(src, dest)
|
|
16
|
-
console.log('sync-cli-defaults:
|
|
21
|
+
console.log('sync-cli-defaults: publish copy → x/bin/helpers/defaults.json')
|
package/x/dist/project/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
import A from"path";import{fileURLToPath as O}from"node:url";import{System as Q,Configs as V,Logger as W,Events as X,Localizations as Y,DtoRuntime as Z,Clients as _,Controller as $,KafkaForCore as v}from"../loader";import{Constants as z,getCore as F,x as K}from"../utils";import{ensureCoreTmpEntry as U,isCorePackageRoot as b}from"../utils/helpers/core/tmp-layout";import{getTmpSnapshot as j}from"../utils/helpers/tmp/tmp-loader";export{ensureCoreTmpEntry,isCorePackageRoot}from"../utils/helpers/core/tmp-layout";export{getTmpSnapshot}from"../utils/helpers/tmp/tmp-loader";export const core=F(),coreInit=async(B)=>{const{locales:q}=B;if(q)globalThis.__LOCAL_MESSAGES__=q};let I=!1;const J=A.dirname(O(import.meta.url)),k=A.join(J,"..","loader","**/*.{ts,js}"),x=A.join(J,"..","utils","**/class.x.{ts,js}"),G=async(B={})=>{if(I)return core;const q=process.cwd();if(b(q))U(q);j();try{await(await K.load([k],{exclude:[x]})).initialize([{service:Q,props:{core}},{service:V,props:{}},{service:v,props:{}},{service:W,props:{}},{service:X,props:{}},{service:Y,props:{}},{service:Z,props:{}},{service:$,props:{}},{service:_,props:{}}]);I=!0;return core}catch(w){const N=w instanceof Error?w.message:String(w);console.error(`[${z.packageName} core failure]: ${N}`);throw w}};export default G;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "@xrystal/core",
|
|
3
3
|
"packageRootFolder": "x",
|
|
4
|
+
"cliName": "xry",
|
|
5
|
+
"cliBinNames": [
|
|
6
|
+
"xry"
|
|
7
|
+
],
|
|
4
8
|
"tmpBaseName": "tmp",
|
|
5
9
|
"tmpExtension": ".yml",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
"templateRepoUri": "https://github.com/xdloper/api-gpt-svc",
|
|
11
|
+
"publicFolderName": "public",
|
|
12
|
+
"kafkaLogsTopic": "log",
|
|
13
|
+
"pathAliasKey": "@/*",
|
|
14
|
+
"eslintRestrictedImportDepth": 2,
|
|
15
|
+
"tmpWatchDefaults": {
|
|
16
|
+
"intervalMs": 500,
|
|
17
|
+
"minIntervalMs": 100,
|
|
18
|
+
"maxIntervalMs": 10000
|
|
11
19
|
},
|
|
12
20
|
"buildDefaults": {
|
|
13
21
|
"tsconfig": "tsconfig.json",
|
|
@@ -16,29 +24,5 @@
|
|
|
16
24
|
"declarations": false,
|
|
17
25
|
"sourcemap": false,
|
|
18
26
|
"minify": false
|
|
19
|
-
}
|
|
20
|
-
"tsconfigDefaults": {
|
|
21
|
-
"pathAliasKey": "@/*",
|
|
22
|
-
"compilerOptions": {
|
|
23
|
-
"noEmit": false,
|
|
24
|
-
"noEmitOnError": false,
|
|
25
|
-
"declaration": true,
|
|
26
|
-
"emitDeclarationOnly": false,
|
|
27
|
-
"sourceMap": false,
|
|
28
|
-
"declarationMap": false,
|
|
29
|
-
"strict": true,
|
|
30
|
-
"noImplicitAny": true
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
"eslintDefaults": {
|
|
34
|
-
"restrictedImportDepth": 2
|
|
35
|
-
},
|
|
36
|
-
"tmpWatchDefaults": {
|
|
37
|
-
"intervalMs": 500,
|
|
38
|
-
"minIntervalMs": 100,
|
|
39
|
-
"maxIntervalMs": 10000
|
|
40
|
-
},
|
|
41
|
-
"publicFolderName": "public",
|
|
42
|
-
"kafkaLogsTopic": "log",
|
|
43
|
-
"templateRepoUri": "https://github.com/xdloper/api-gpt-svc"
|
|
27
|
+
}
|
|
44
28
|
}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import defaults from './defaults.json';
|
|
2
|
-
export type PackageDefaults = typeof defaults
|
|
3
|
-
|
|
4
|
-
layoutPaths:
|
|
5
|
-
|
|
2
|
+
export type PackageDefaults = typeof defaults & {
|
|
3
|
+
mainSourceFolder: string;
|
|
4
|
+
layoutPaths: {
|
|
5
|
+
tests: string;
|
|
6
|
+
environments: string;
|
|
7
|
+
dist: string;
|
|
8
|
+
};
|
|
9
|
+
cliBinNames: readonly string[];
|
|
10
|
+
};
|
|
11
|
+
export declare const packageDefaults: Readonly<PackageDefaults>;
|
|
6
12
|
export declare const coreVersionPattern: RegExp;
|
|
7
13
|
export declare const semverVersionPattern: RegExp;
|
|
8
14
|
export declare class Constants {
|
|
@@ -10,18 +16,20 @@ export declare class Constants {
|
|
|
10
16
|
static readonly packageRootFolder: string;
|
|
11
17
|
static readonly tmpBaseName: string;
|
|
12
18
|
static readonly tmpExtension: string;
|
|
19
|
+
static readonly publicFolderName: string;
|
|
20
|
+
static readonly kafkaLogsTopic: string;
|
|
21
|
+
static readonly templateRepoUri: string;
|
|
22
|
+
static readonly cliName: string;
|
|
23
|
+
static readonly cliBinNames: string[] & readonly string[];
|
|
24
|
+
static readonly pathAliasKey: string;
|
|
25
|
+
/** From bundled x/tmp.yml — used only when project tmp.yml omits paths */
|
|
13
26
|
static readonly mainSourceFolder: string;
|
|
14
27
|
static readonly layoutPaths: {
|
|
15
28
|
tests: string;
|
|
16
29
|
environments: string;
|
|
17
30
|
dist: string;
|
|
18
|
-
}
|
|
19
|
-
tests: string;
|
|
20
|
-
environments: string;
|
|
21
|
-
dist: string;
|
|
22
|
-
}>;
|
|
23
|
-
static readonly publicFolderName: string;
|
|
24
|
-
static readonly kafkaLogsTopic: string;
|
|
25
|
-
static readonly templateRepoUri: string;
|
|
31
|
+
};
|
|
26
32
|
static readonly bundledCoreTmpPath: string;
|
|
27
33
|
}
|
|
34
|
+
/** Stable public re-exports — implementation lives in helpers/tmp. */
|
|
35
|
+
export { seedFromTmp, loadSeedFromBundledTmp } from '../../utils/helpers/tmp/seed-from-tmp';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import n from"node:path";import{packageRootDir as q}from"../../utils/package-root";import b from"./defaults.json" with { type: 'json' };import{seedFromTmp as j}from"../../utils/helpers/tmp/seed-from-tmp";export const packageDefaults=Object.freeze({...b,mainSourceFolder:j.sourceFolder,layoutPaths:Object.freeze({...j.layout}),buildDefaults:Object.freeze({...b.buildDefaults}),tmpWatchDefaults:Object.freeze({...b.tmpWatchDefaults}),cliBinNames:Object.freeze([...b.cliBinNames??[b.cliName]])}),coreVersionPattern=/^\d{2}\.\d{2}\.\d{2}-v\d+$/,semverVersionPattern=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?$/;const v=`${packageDefaults.tmpBaseName}${packageDefaults.tmpExtension}`;export class Constants{static packageName=packageDefaults.packageName;static packageRootFolder=packageDefaults.packageRootFolder;static tmpBaseName=packageDefaults.tmpBaseName;static tmpExtension=packageDefaults.tmpExtension;static publicFolderName=packageDefaults.publicFolderName;static kafkaLogsTopic=packageDefaults.kafkaLogsTopic;static templateRepoUri=packageDefaults.templateRepoUri;static cliName=packageDefaults.cliName;static cliBinNames=packageDefaults.cliBinNames;static pathAliasKey=packageDefaults.pathAliasKey;static mainSourceFolder=packageDefaults.mainSourceFolder;static layoutPaths=packageDefaults.layoutPaths;static bundledCoreTmpPath=n.join(q,packageDefaults.packageRootFolder,v)}export{seedFromTmp,loadSeedFromBundledTmp}from"../../utils/helpers/tmp/seed-from-tmp";
|
|
@@ -3,3 +3,5 @@ export { getTmpLoader, getTmpLoaderPath, getTmpSnapshot, onTmpReload, resetTmpLo
|
|
|
3
3
|
export { bindLoaderTmpSync, type ITmpSyncLoader, } from '../../../utils/helpers/tmp/loader-tmp-sync';
|
|
4
4
|
export { resolveTmpWatchIntervalMs } from '../../../utils/helpers/tmp/tmp-watch';
|
|
5
5
|
export { normalizeTmpDocument, normalizeRootFolder, normalizeSourceFolder, readTmpCoreBlock, readTmpServiceBlock, resolveServiceLayoutPaths, resolveTmpRuntimeConfigs, } from '../../../utils/helpers/tmp/tmp-schema';
|
|
6
|
+
export { loadSeedFromBundledTmp, seedFromTmp, type SeedFromTmp, type SeedLayoutPaths, } from '../../../utils/helpers/tmp/seed-from-tmp';
|
|
7
|
+
export { DEFAULT_LAYOUT_PATHS, normalizeLayoutPaths, type LayoutPaths, } from '../../../utils/helpers/tmp/path-normalize';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export{setRuntimeTmpConfigs,getRuntimeTmpConfigs,onRuntimeTmpChange,notifyRuntimeTmpChange,clearRuntimeTmpConfigs}from"../../../utils/helpers/tmp/runtime-tmp";export{getTmpLoader,getTmpLoaderPath,getTmpSnapshot,onTmpReload,resetTmpLoaderForTests,stopTmpLoader}from"../../../utils/helpers/tmp/tmp-loader";export{bindLoaderTmpSync}from"../../../utils/helpers/tmp/loader-tmp-sync";export{resolveTmpWatchIntervalMs}from"../../../utils/helpers/tmp/tmp-watch";export{normalizeTmpDocument,normalizeRootFolder,normalizeSourceFolder,readTmpCoreBlock,readTmpServiceBlock,resolveServiceLayoutPaths,resolveTmpRuntimeConfigs}from"../../../utils/helpers/tmp/tmp-schema";
|
|
1
|
+
export{setRuntimeTmpConfigs,getRuntimeTmpConfigs,onRuntimeTmpChange,notifyRuntimeTmpChange,clearRuntimeTmpConfigs}from"../../../utils/helpers/tmp/runtime-tmp";export{getTmpLoader,getTmpLoaderPath,getTmpSnapshot,onTmpReload,resetTmpLoaderForTests,stopTmpLoader}from"../../../utils/helpers/tmp/tmp-loader";export{bindLoaderTmpSync}from"../../../utils/helpers/tmp/loader-tmp-sync";export{resolveTmpWatchIntervalMs}from"../../../utils/helpers/tmp/tmp-watch";export{normalizeTmpDocument,normalizeRootFolder,normalizeSourceFolder,readTmpCoreBlock,readTmpServiceBlock,resolveServiceLayoutPaths,resolveTmpRuntimeConfigs}from"../../../utils/helpers/tmp/tmp-schema";export{loadSeedFromBundledTmp,seedFromTmp}from"../../../utils/helpers/tmp/seed-from-tmp";export{DEFAULT_LAYOUT_PATHS,normalizeLayoutPaths}from"../../../utils/helpers/tmp/path-normalize";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Pure path normalizers — no Constants / no I/O (shared by seed + schema). */
|
|
2
|
+
export type LayoutPaths = {
|
|
3
|
+
tests: string;
|
|
4
|
+
environments: string;
|
|
5
|
+
dist: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const DEFAULT_LAYOUT_PATHS: Readonly<LayoutPaths>;
|
|
8
|
+
export declare function normalizeRootFolder(value: unknown, fallback?: string): string;
|
|
9
|
+
export declare function normalizeSourceFolder(value: unknown, fallback?: string): string;
|
|
10
|
+
export declare function normalizeLayoutPaths(special: unknown, fallback?: LayoutPaths): LayoutPaths;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_LAYOUT_PATHS=Object.freeze({tests:"tests",environments:"environments",dist:"dist"});export function normalizeRootFolder(t,n="x"){if(typeof t!=="string"||!t.trim())return n;return t.trim().replace(/^\.\/+/,"")}export function normalizeSourceFolder(t,n="./source"){if(typeof t!=="string"||!t.trim())return n;const r=t.trim();if(r.startsWith("./")||r.startsWith("../"))return r;return`./${r}`}export function normalizeLayoutPaths(t,n=DEFAULT_LAYOUT_PATHS){const r=t&&typeof t==="object"&&!Array.isArray(t)?t:{},e=(s)=>{const o=r[s];return typeof o==="string"&&o.trim()?o.trim():n[s]};return{tests:e("tests"),environments:e("environments"),dist:e("dist")}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type LayoutPaths } from '../../../utils/helpers/tmp/path-normalize';
|
|
2
|
+
export type SeedLayoutPaths = LayoutPaths;
|
|
3
|
+
export type SeedFromTmp = {
|
|
4
|
+
rootFolder: string;
|
|
5
|
+
sourceFolder: string;
|
|
6
|
+
layout: SeedLayoutPaths;
|
|
7
|
+
};
|
|
8
|
+
export declare function loadSeedFromBundledTmp(tmpFilePath?: string): SeedFromTmp;
|
|
9
|
+
export declare const seedFromTmp: SeedFromTmp;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import I from"node:fs";import N from"node:path";import Q from"yaml";import j from"../../../utils/constants/defaults.json" with { type: 'json' };import{packageRootDir as V}from"../../../utils/package-root";import{DEFAULT_LAYOUT_PATHS as J,normalizeLayoutPaths as W,normalizeRootFolder as X,normalizeSourceFolder as Z}from"../../../utils/helpers/tmp/path-normalize";export function loadSeedFromBundledTmp(K){const G=K??N.join(V,j.packageRootFolder,`${j.tmpBaseName}${j.tmpExtension}`),M={rootFolder:j.packageRootFolder,sourceFolder:"./source",layout:{...J}};if(!I.existsSync(G))return M;const q=Q.parse(I.readFileSync(G,"utf8")),w=q?.configs&&typeof q.configs==="object"?q.configs:{},x=w.service&&typeof w.service==="object"?w.service:{},C=x.paths&&typeof x.paths==="object"?x.paths:{};return{rootFolder:X(C.root,j.packageRootFolder),sourceFolder:Z(C.source,"./source"),layout:W(C.special,J)}}export const seedFromTmp=loadSeedFromBundledTmp();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import J from"node:fs";import K from"node:path";import{Constants as
|
|
1
|
+
import J from"node:fs";import K from"node:path";import{Constants as z}from"../../../utils/constants";import{assertCoreTmpGuard as M,coreCanonicalTmpPath as O,isCorePackageRoot as Q}from"../../../utils/helpers/core/tmp-layout";import{findFileRecursively as U}from"../../../utils/helpers/core/paths";import{TmpFileLoader as V}from"../../../utils/models/classes/class.tmp-file-loader";import{registerGracefulShutdown as W}from"../../../utils/helpers/runtime/shutdown";let q=null,B=null;function X(D=process.cwd(),j=z.tmpBaseName,b=z.tmpExtension){const A=K.resolve(D);if(Q(A)){const E=O(A);if(!J.existsSync(E))throw Error(`${z.packageRootFolder}/tmp.yml not found. Run ${z.cliName} tmp or ensureCoreTmpEntry() before starting ${z.packageName}`);M(A,E);return E}const H=U(A,j,b);if(!H)throw Error(`${j}${b.startsWith(".")?b:`.${b}`} file not found`);return H}export function getTmpLoaderPath(){if(!B)B=X();return B}export function getTmpLoader(){if(!q){q=new V({filePath:getTmpLoaderPath()});W()}return q}export function getTmpSnapshot(){return getTmpLoader().getResolvedTmpFile()}export function onTmpReload(D){const j=getTmpLoader(),b=()=>D(j.getResolvedTmpFile());j.on("reload",b);return()=>j.off("reload",b)}export function stopTmpLoader(){if(q){q.stop();q=null;B=null}}export function resetTmpLoaderForTests(){stopTmpLoader()}
|
|
@@ -41,6 +41,7 @@ export declare function normalizeRootFolder(value?: string): string;
|
|
|
41
41
|
export declare function normalizeSourceFolder(value?: string): string;
|
|
42
42
|
export declare function readTmpCoreBlock(configs?: Record<string, unknown>): TmpCoreBlock;
|
|
43
43
|
export declare function readTmpServiceBlock(configs?: Record<string, unknown>): TmpServiceBlock;
|
|
44
|
+
/** Project layout from tmp.yml; omitted specials → bootstrap layout (same as bundled x/tmp.yml). */
|
|
44
45
|
export declare function resolveServiceLayoutPaths(service: TmpServiceBlock): TmpLayoutPathsFlat;
|
|
45
46
|
/** Canonical tmp.yml shape — `service` + `core` + derived `rootFolderPath`. */
|
|
46
47
|
export declare function resolveTmpRuntimeConfigs(tmp?: Record<string, unknown> | null): TmpRuntimeConfigs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import X from"../../../utils/constants/defaults.json" with { type: 'json' };import{DEFAULT_LAYOUT_PATHS as D,normalizeLayoutPaths as H,normalizeRootFolder as I,normalizeSourceFolder as W}from"../../../utils/helpers/tmp/path-normalize";const Z="./source";function G(j){return typeof j==="object"&&j!==null&&!Array.isArray(j)}function Y(j){if(typeof j==="number"||typeof j==="string")return j;return}export function normalizeRootFolder(j){return I(j,X.packageRootFolder)}export function normalizeSourceFolder(j){return W(j,Z)}export function readTmpCoreBlock(j){const q=G(j?.core)?j.core:{},x=G(q.tmp)?q.tmp:{};return{tmp:{fileWatchIntervalMs:Y(x.fileWatchIntervalMs)}}}export function readTmpServiceBlock(j){const q=G(j?.service)?j.service:{},x=G(q.paths)?q.paths:{},J=G(x.special)?x.special:{};let K=G(q.loaders)?{...q.loaders}:void 0,M=G(q.build)?q.build:void 0;if(K&&G(K.build)){const{build:Q,...$}=K;K=$;if(!M&&G(Q))M=Q}return{name:typeof q.name==="string"?q.name:void 0,framework:typeof q.framework==="string"?q.framework:void 0,paths:{root:typeof x.root==="string"?x.root:void 0,source:typeof x.source==="string"?x.source:void 0,special:{tests:typeof J.tests==="string"?J.tests:void 0,environments:typeof J.environments==="string"?J.environments:void 0,dist:typeof J.dist==="string"?J.dist:void 0}},protocols:q.protocols,loaders:K,build:M}}export function resolveServiceLayoutPaths(j){return H(j.paths?.special,D)}function k(j){const q=resolveServiceLayoutPaths(j);return{name:j.name,framework:j.framework??"elysia",paths:{root:j.paths?.root??X.packageRootFolder,source:j.paths?.source??Z,special:q},protocols:j.protocols,loaders:j.loaders,build:j.build}}function N(j){return{tmp:{fileWatchIntervalMs:j.tmp?.fileWatchIntervalMs}}}export function resolveTmpRuntimeConfigs(j){const q=G(j?.configs)?j.configs:{},x=readTmpServiceBlock(q),J=readTmpCoreBlock(q),K=k(x);return{service:K,core:N(J),rootFolderPath:normalizeRootFolder(K.paths.root)}}export function normalizeTmpDocument(j){return{...j,configs:resolveTmpRuntimeConfigs(j)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import I
|
|
1
|
+
import{packageDefaults as I}from"../../../utils/constants";import{readTmpCoreBlock as J}from"../../../utils/helpers/tmp/tmp-schema";const b=I.tmpWatchDefaults;export function resolveTmpWatchIntervalMs(q){const v=q?.configs,y=J(v).tmp?.fileWatchIntervalMs??b.intervalMs,j=Number(y);if(!Number.isFinite(j))return b.intervalMs;const z=b.minIntervalMs??100,G=b.maxIntervalMs??1e4;return Math.min(G,Math.max(z,Math.round(j)))}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import { printCommandHeader } from '../helpers/banner.mjs'
|
|
3
|
-
import { readCliPackageJson } from '../helpers/project-root.mjs'
|
|
4
|
-
|
|
5
|
-
import { syncProjectToolchain, auditTsconfigAlignment } from '../helpers/toolchain-config.mjs'
|
|
6
|
-
import { getProjectRoot } from '../helpers/project-root.mjs'
|
|
7
|
-
|
|
8
|
-
export function registerSyncToolchainCommand(cli, { cliName = 'xcore' } = {}) {
|
|
9
|
-
cli
|
|
10
|
-
.command('sync-toolchain')
|
|
11
|
-
.description('Sync tsconfig paths from tmp.yml layout')
|
|
12
|
-
.option('--dry-run', 'Show changes without writing tsconfig.json')
|
|
13
|
-
.action((options) => {
|
|
14
|
-
const root = getProjectRoot()
|
|
15
|
-
const auditBefore = auditTsconfigAlignment(root)
|
|
16
|
-
|
|
17
|
-
printCommandHeader({ cliName, command: 'sync-toolchain', version: readCliPackageJson().version })
|
|
18
|
-
console.log(chalk.gray(` root: ${root}`))
|
|
19
|
-
|
|
20
|
-
const lo = auditBefore.layoutOptions ?? {}
|
|
21
|
-
console.log(chalk.gray(' tmp.yml layout:'))
|
|
22
|
-
console.log(chalk.gray(` paths.root: ${lo.rootFolderPath ?? 'x'}`))
|
|
23
|
-
console.log(chalk.gray(` paths.source: ${lo.mainFolderPath ?? './source'}`))
|
|
24
|
-
console.log(chalk.gray(` paths.dist: ${lo.pathsDist ?? 'dist'}`))
|
|
25
|
-
|
|
26
|
-
if (options.dryRun) {
|
|
27
|
-
const preview = syncProjectToolchain(root, { write: false })
|
|
28
|
-
console.log(chalk.gray('\n would write tsconfig.json:'))
|
|
29
|
-
console.log(chalk.gray(` include: ${JSON.stringify(preview.merged.include)}`))
|
|
30
|
-
console.log(chalk.gray(` outDir: ${preview.merged.compilerOptions.outDir}`))
|
|
31
|
-
console.log(chalk.gray(` paths: ${JSON.stringify(preview.merged.compilerOptions.paths)}`))
|
|
32
|
-
console.log(chalk.gray(`\n bunfig.toml → ${preview.paths.bunfigAliasLine}\n`))
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const result = syncProjectToolchain(root, { write: true })
|
|
37
|
-
console.log(result.created ? chalk.green(` created ${result.tsconfigRel}`) : chalk.green(` updated ${result.tsconfigRel}`))
|
|
38
|
-
console.log(chalk.gray(` include → ${JSON.stringify(result.merged.include)}`))
|
|
39
|
-
console.log(chalk.gray(` outDir → ${result.merged.compilerOptions.outDir}`))
|
|
40
|
-
console.log(chalk.gray(` eslint → ${result.paths.eslintFiles.join(', ')}`))
|
|
41
|
-
console.log(chalk.yellow(`\n bunfig.toml [resolve.alias]: ${result.paths.bunfigAliasLine}\n`))
|
|
42
|
-
})
|
|
43
|
-
}
|