@xrystal/core 3.37.3 → 3.37.4
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 +33 -8
- package/package.json +6 -6
- package/x/bin/helpers/project-artifacts.mjs +10 -8
- package/x/bin/scripts/prepare-npm-publish.mjs +7 -17
- package/x/bin/scripts/publish-guard.mjs +113 -0
- package/x/bin/scripts/verify-npm-pack.mjs +9 -42
- package/x/bin/scripts/verify-publish-config.mjs +10 -0
- package/x/dist/index.d.ts +1 -3
- package/x/dist/index.js +1 -1
- package/x/dist/project/index.d.ts +6 -2
- package/x/dist/project/index.js +1 -1
- package/x/bin/scripts/unpublish-leaked-versions.mjs +0 -62
package/README.md
CHANGED
|
@@ -7,6 +7,31 @@
|
|
|
7
7
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
|
+
## npm publish / npm yayın
|
|
11
|
+
|
|
12
|
+
| | **EN** | **TR** |
|
|
13
|
+
|---|--------|--------|
|
|
14
|
+
| **Ships** | `x/dist` (minified `.js` + `.d.ts`), `x/bin`, `x/tmp.yml`, `x/assets` | Aynı — yalnızca bunlar |
|
|
15
|
+
| **Never** | `source/` `.ts` in npm | npm'e `source/` `.ts` **asla** gitmez |
|
|
16
|
+
| **Runtime** | `main` / `exports` → `x/dist/` | `main` / `exports` → `x/dist/` |
|
|
17
|
+
|
|
18
|
+
**EN — 3 publish checks (all must pass):**
|
|
19
|
+
1. `package.json` `files` — no `source/`, `main`/`exports` → `x/dist`
|
|
20
|
+
2. `npm pack --dry-run` — no `source/` paths
|
|
21
|
+
3. CI: `prepare-npm-publish` → `verify-npm-pack` (strict: disk + minify)
|
|
22
|
+
|
|
23
|
+
**TR — 3 publish kontrolü (hepsi geçmeli):**
|
|
24
|
+
1. `package.json` `files` — `source/` yok, `main`/`exports` → `x/dist`
|
|
25
|
+
2. `npm pack --dry-run` — `source/` yok
|
|
26
|
+
3. CI: `prepare-npm-publish` → `verify-npm-pack` (strict: disk + minify)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
bun run release:prepare # lint → build → test
|
|
30
|
+
node x/bin/scripts/verify-publish-config.mjs # local prepublish gate
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
10
35
|
## `tmp.yml` layout / tmp.yml düzeni
|
|
11
36
|
|
|
12
37
|
**EN — structure:** `service` (app identity, paths, runtime, build) + `core` (library mechanisms like tmp watch).
|
|
@@ -78,7 +103,7 @@ In one sentence: **`tmp.yml` is the project key** — `@xrystal/core` reads it,
|
|
|
78
103
|
|
|
79
104
|
**Boot:** `ensureCoreTmpEntry()` → `getTmpSnapshot()` → `coreLoader()` → loaders `syncFromTmp()`.
|
|
80
105
|
|
|
81
|
-
|
|
106
|
+
See [npm publish / npm yayın](#npm-publish--npm-yayın) for what ships to npm.
|
|
82
107
|
|
|
83
108
|
---
|
|
84
109
|
|
|
@@ -99,7 +124,7 @@ Tek cümle: **`tmp.yml` projenin anahtarı** — `@xrystal/core` onu okuyup load
|
|
|
99
124
|
|
|
100
125
|
**Boot:** `ensureCoreTmpEntry()` → `getTmpSnapshot()` → `coreLoader()` → loader’lar `syncFromTmp()`.
|
|
101
126
|
|
|
102
|
-
|
|
127
|
+
npm için → [npm publish / npm yayın](#npm-publish--npm-yayın).
|
|
103
128
|
|
|
104
129
|
---
|
|
105
130
|
|
|
@@ -1782,9 +1807,9 @@ configs:
|
|
|
1782
1807
|
|
|
1783
1808
|
**TR — build sırası (@xrystal/core lib):** `rm x/dist` → `tsc` → `tsc-alias` → `fix-dist-imports` → `minify-dist?` (`build.minify`)
|
|
1784
1809
|
|
|
1785
|
-
**EN:** `prepublishOnly`
|
|
1810
|
+
**EN:** `prepublishOnly` = `release:prepare` + `verify-publish-config`. See [npm publish](#npm-publish--npm-yayın).
|
|
1786
1811
|
|
|
1787
|
-
**TR:** `prepublishOnly`
|
|
1812
|
+
**TR:** `prepublishOnly` = `release:prepare` + `verify-publish-config`. Bkz. [npm publish](#npm-publish--npm-yayın).
|
|
1788
1813
|
|
|
1789
1814
|
```bash
|
|
1790
1815
|
xcore build
|
|
@@ -1833,9 +1858,9 @@ xcore start # bun x/dist/index.js (+ .global.env / .prod.env if present)
|
|
|
1833
1858
|
3. **EN:** `git tag vX.Y.Z` + push → GitHub Actions publishes to npm.
|
|
1834
1859
|
**TR:** Tag + push → CI npm’e publish eder.
|
|
1835
1860
|
|
|
1836
|
-
**EN:** Never commit
|
|
1861
|
+
**EN:** Never commit `.js` under `source/`. Publish uses minified `x/dist` only — [npm publish](#npm-publish--npm-yayın).
|
|
1837
1862
|
|
|
1838
|
-
**TR:** `source/` altına
|
|
1863
|
+
**TR:** `source/` altına `.js` commit etme. Publish yalnızca minify `x/dist` — [npm publish](#npm-publish--npm-yayın).
|
|
1839
1864
|
|
|
1840
1865
|
**EN:** Service `npm run tag` does not publish `@xrystal/core` — use `xcore tag` or `"release:tag": "xcore tag"` on the **service** repo.
|
|
1841
1866
|
|
|
@@ -2295,9 +2320,9 @@ bun run build # tsc → x/dist (+ fix-dist-imports; minify if tmp
|
|
|
2295
2320
|
**EN:** Lightweight unit/integration tests (no full Awilix boot in most suites). Path alias `@/*` → `./source/*` via `bunfig.toml`.
|
|
2296
2321
|
**TR:** Hafif unit/integration testleri (çoğu suite’te tam Awilix boot yok). `@/*` alias `bunfig.toml` ile çözülür.
|
|
2297
2322
|
|
|
2298
|
-
**EN:** Publish CI: `lint` → `build` → `test` → `prepare-npm-publish`
|
|
2323
|
+
**EN:** Publish CI: `lint` → `build` → `test` → `prepare-npm-publish` → `verify-npm-pack` → `npm publish`. Details: [npm publish](#npm-publish--npm-yayın).
|
|
2299
2324
|
|
|
2300
|
-
**TR:** Publish CI: `lint` → `build` → `test` → `prepare-npm-publish`
|
|
2325
|
+
**TR:** Publish CI: `lint` → `build` → `test` → `prepare-npm-publish` → `verify-npm-pack` → `npm publish`. Detay: [npm publish](#npm-publish--npm-yayın).
|
|
2301
2326
|
|
|
2302
2327
|
`express` is a **devDependency** only — not shipped to apps / uygulamalara gitmez.
|
|
2303
2328
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Yusuf Yasir KAYGUSUZ",
|
|
3
3
|
"name": "@xrystal/core",
|
|
4
|
-
"version": "3.37.
|
|
4
|
+
"version": "3.37.4",
|
|
5
5
|
"description": "Project core for xrystal",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
"tsconfig.base.json",
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
|
-
"main": "./x/dist/index.js",
|
|
23
|
-
"types": "./x/dist/index.d.ts",
|
|
22
|
+
"main": "./x/dist/project/index.js",
|
|
23
|
+
"types": "./x/dist/project/index.d.ts",
|
|
24
24
|
"exports": {
|
|
25
25
|
"./tsconfig.base.json": "./tsconfig.base.json",
|
|
26
26
|
".": {
|
|
27
|
-
"types": "./x/dist/index.d.ts",
|
|
28
|
-
"default": "./x/dist/index.js"
|
|
27
|
+
"types": "./x/dist/project/index.d.ts",
|
|
28
|
+
"default": "./x/dist/project/index.js"
|
|
29
29
|
},
|
|
30
30
|
"./utils": {
|
|
31
31
|
"types": "./x/dist/utils/index.d.ts",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"build": "node x/bin/main-cli.js build",
|
|
60
60
|
"test": "bun test x/tests",
|
|
61
61
|
"lint": "eslint source",
|
|
62
|
-
"prepublishOnly": "bun run release:prepare",
|
|
62
|
+
"prepublishOnly": "bun run release:prepare && node x/bin/scripts/verify-publish-config.mjs",
|
|
63
63
|
"release:prepare": "bun run lint && bun run build && bun test x/tests",
|
|
64
64
|
"build:prod": "bun run release:prepare && node x/bin/scripts/clean-source-types.mjs",
|
|
65
65
|
"build:dev": "node x/bin/main-cli.js dev",
|
|
@@ -12,7 +12,6 @@ const CLI_GENERATED_SCHEMA = path.join(CLI_BIN_DIR, '.generated/tmp-schema.mjs')
|
|
|
12
12
|
const CLI_SCHEMA_SOURCE = 'source/utils/helpers/tmp/tmp-schema.ts'
|
|
13
13
|
|
|
14
14
|
const CORE_EXPORT_SUBPATHS = [
|
|
15
|
-
'',
|
|
16
15
|
'utils',
|
|
17
16
|
'loader',
|
|
18
17
|
'loader/controller',
|
|
@@ -37,16 +36,19 @@ export function resolveDistLayout(root = process.cwd()) {
|
|
|
37
36
|
|
|
38
37
|
export function buildCorePackageExports(distPrefix) {
|
|
39
38
|
const base = distPrefix.replace(/\/$/, '')
|
|
39
|
+
const mainEntry = `${base}/project/index`
|
|
40
40
|
const exports = {
|
|
41
41
|
'./tsconfig.base.json': './tsconfig.base.json',
|
|
42
|
+
'.': {
|
|
43
|
+
types: `${mainEntry}.d.ts`,
|
|
44
|
+
default: `${mainEntry}.js`,
|
|
45
|
+
},
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
for (const sub of CORE_EXPORT_SUBPATHS) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
types: `${base}${suffix}/index.d.ts`,
|
|
49
|
-
default: `${base}${suffix}/index.js`,
|
|
49
|
+
exports[`./${sub}`] = {
|
|
50
|
+
types: `${base}/${sub}/index.d.ts`,
|
|
51
|
+
default: `${base}/${sub}/index.js`,
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -105,8 +107,8 @@ export function syncPackageManifest(root = process.cwd(), { write = true } = {})
|
|
|
105
107
|
const { distPrefix, distRel } = resolveDistLayout(root)
|
|
106
108
|
const next = {
|
|
107
109
|
...pkg,
|
|
108
|
-
main: `${distPrefix}/index.js`,
|
|
109
|
-
types: `${distPrefix}/index.d.ts`,
|
|
110
|
+
main: `${distPrefix}/project/index.js`,
|
|
111
|
+
types: `${distPrefix}/project/index.d.ts`,
|
|
110
112
|
exports: buildCorePackageExports(distPrefix),
|
|
111
113
|
files: normalizeFilesList(pkg.files, distRel),
|
|
112
114
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import fs from 'node:fs'
|
|
3
3
|
import path from 'node:path'
|
|
4
|
+
import { PublishGuardError, runPublishGuards } from './publish-guard.mjs'
|
|
4
5
|
|
|
5
6
|
const root = process.cwd()
|
|
6
7
|
|
|
@@ -24,26 +25,15 @@ for (const rel of pathsToRemove) {
|
|
|
24
25
|
console.log(`prepare-npm-publish: removed ${rel}`)
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
function countDistJs(dir) {
|
|
29
|
-
for (const name of fs.readdirSync(dir)) {
|
|
30
|
-
const abs = path.join(dir, name)
|
|
31
|
-
const stat = fs.statSync(abs)
|
|
32
|
-
if (stat.isDirectory()) countDistJs(abs)
|
|
33
|
-
else if (name.endsWith('.js')) distJs.push(abs)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const distDir = path.join(root, 'x', 'dist')
|
|
38
|
-
if (!fs.existsSync(distDir)) {
|
|
28
|
+
if (!fs.existsSync(path.join(root, 'x', 'dist'))) {
|
|
39
29
|
console.error('prepare-npm-publish: x/dist missing — run build first')
|
|
40
30
|
process.exit(1)
|
|
41
31
|
}
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
console.
|
|
33
|
+
try {
|
|
34
|
+
const { jsCount } = runPublishGuards(root, { strictDisk: true })
|
|
35
|
+
console.log(`prepare-npm-publish: ready (${jsCount} .js in x/dist, verified)`)
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(`prepare-npm-publish: ✗ ${error instanceof PublishGuardError ? error.message : error.message}`)
|
|
46
38
|
process.exit(1)
|
|
47
39
|
}
|
|
48
|
-
|
|
49
|
-
console.log(`prepare-npm-publish: ready (${distJs.length} .js in x/dist, no source/)`)
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process'
|
|
2
|
+
import fs from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
export class PublishGuardError extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message)
|
|
8
|
+
this.name = 'PublishGuardError'
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function readPackage(root = process.cwd()) {
|
|
13
|
+
return JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function assertFilesListNoSource(pkg) {
|
|
17
|
+
const files = Array.isArray(pkg.files) ? pkg.files : []
|
|
18
|
+
const bad = files.filter((entry) => {
|
|
19
|
+
const normalized = String(entry).replace(/^\.\//, '').replace(/\\/g, '/')
|
|
20
|
+
return normalized === 'source' || normalized.startsWith('source/')
|
|
21
|
+
})
|
|
22
|
+
if (bad.length > 0) {
|
|
23
|
+
throw new PublishGuardError(`package.json files must not include source/ (found: ${bad.join(', ')})`)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function assertFilesListHasDist(pkg) {
|
|
28
|
+
const files = Array.isArray(pkg.files) ? pkg.files : []
|
|
29
|
+
if (!files.some((entry) => String(entry).replace(/^\.\//, '').includes('dist'))) {
|
|
30
|
+
throw new PublishGuardError('package.json files must include x/dist')
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function assertMainExportsPointToDist(pkg) {
|
|
35
|
+
const main = String(pkg.main ?? '')
|
|
36
|
+
if (!main.includes('/dist/')) {
|
|
37
|
+
throw new PublishGuardError(`package.json main must point to x/dist (got ${main || 'empty'})`)
|
|
38
|
+
}
|
|
39
|
+
const exports = pkg.exports ?? {}
|
|
40
|
+
for (const [key, value] of Object.entries(exports)) {
|
|
41
|
+
if (key === './tsconfig.base.json') continue
|
|
42
|
+
const target = typeof value === 'string' ? value : value?.default
|
|
43
|
+
if (target && !String(target).includes('/dist/')) {
|
|
44
|
+
throw new PublishGuardError(`exports[${key}] must point to x/dist (got ${target})`)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function assertSourceAbsentOnDisk(root = process.cwd()) {
|
|
50
|
+
if (fs.existsSync(path.join(root, 'source'))) {
|
|
51
|
+
throw new PublishGuardError('source/ must not exist on disk at publish time')
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function countDistJs(root = process.cwd()) {
|
|
56
|
+
const distDir = path.join(root, 'x', 'dist')
|
|
57
|
+
if (!fs.existsSync(distDir)) return 0
|
|
58
|
+
let count = 0
|
|
59
|
+
const walk = (dir) => {
|
|
60
|
+
for (const name of fs.readdirSync(dir)) {
|
|
61
|
+
const abs = path.join(dir, name)
|
|
62
|
+
if (fs.statSync(abs).isDirectory()) walk(abs)
|
|
63
|
+
else if (name.endsWith('.js')) count += 1
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
walk(distDir)
|
|
67
|
+
return count
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function assertDistTree(root = process.cwd(), minJs = 10) {
|
|
71
|
+
const distIndex = path.join(root, 'x/dist/index.js')
|
|
72
|
+
if (!fs.existsSync(distIndex)) {
|
|
73
|
+
throw new PublishGuardError('x/dist/index.js missing — run build first')
|
|
74
|
+
}
|
|
75
|
+
const jsCount = countDistJs(root)
|
|
76
|
+
if (jsCount < minJs) {
|
|
77
|
+
throw new PublishGuardError(`x/dist incomplete (${jsCount} .js files, need >= ${minJs})`)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function assertDistMinified(root = process.cwd()) {
|
|
82
|
+
const indexJs = fs.readFileSync(path.join(root, 'x/dist/index.js'), 'utf8')
|
|
83
|
+
const lines = indexJs.split('\n').filter((line) => line.trim().length > 0)
|
|
84
|
+
const looksReadable = lines.length > 3 && indexJs.includes("from './") && !indexJs.includes('from"')
|
|
85
|
+
if (looksReadable) {
|
|
86
|
+
throw new PublishGuardError('x/dist/index.js looks unminified — enable build.minify before publish')
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function assertNpmPackClean(root = process.cwd()) {
|
|
91
|
+
const dryRun = execSync('npm pack --dry-run 2>&1', { cwd: root, encoding: 'utf8' })
|
|
92
|
+
if (/source\/.*\.ts/.test(dryRun) || /npm notice.*source\//.test(dryRun)) {
|
|
93
|
+
throw new PublishGuardError('npm pack tarball lists source/ — TypeScript source must not ship')
|
|
94
|
+
}
|
|
95
|
+
if (!/x\/dist\/.*\.js/.test(dryRun)) {
|
|
96
|
+
throw new PublishGuardError('npm pack tarball must include x/dist/**/*.js')
|
|
97
|
+
}
|
|
98
|
+
return dryRun
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function runPublishGuards(root = process.cwd(), { strictDisk = false } = {}) {
|
|
102
|
+
const pkg = readPackage(root)
|
|
103
|
+
assertFilesListNoSource(pkg)
|
|
104
|
+
assertFilesListHasDist(pkg)
|
|
105
|
+
assertMainExportsPointToDist(pkg)
|
|
106
|
+
assertDistTree(root)
|
|
107
|
+
assertNpmPackClean(root)
|
|
108
|
+
if (strictDisk) {
|
|
109
|
+
assertSourceAbsentOnDisk(root)
|
|
110
|
+
assertDistMinified(root)
|
|
111
|
+
}
|
|
112
|
+
return { pkg, jsCount: countDistJs(root) }
|
|
113
|
+
}
|
|
@@ -1,45 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
console.error(`verify-npm-pack: ✗ ${message}`)
|
|
2
|
+
import { PublishGuardError, runPublishGuards } from './publish-guard.mjs'
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
const { jsCount } = runPublishGuards(process.cwd(), { strictDisk: true })
|
|
6
|
+
console.log('verify-npm-pack: ✓ package.json files — no source/')
|
|
7
|
+
console.log('verify-npm-pack: ✓ main/exports → x/dist')
|
|
8
|
+
console.log(`verify-npm-pack: ✓ npm pack clean (${jsCount} .js, minified)`)
|
|
9
|
+
} catch (error) {
|
|
10
|
+
console.error(`verify-npm-pack: ✗ ${error instanceof PublishGuardError ? error.message : error.message}`)
|
|
11
11
|
process.exit(1)
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
if (fs.existsSync(path.join(root, 'source'))) {
|
|
15
|
-
fail('source/ still exists on disk — run prepare-npm-publish.mjs first')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const files = Array.isArray(pkg.files) ? pkg.files : []
|
|
19
|
-
if (files.some((entry) => {
|
|
20
|
-
const normalized = String(entry).replace(/^\.\//, '')
|
|
21
|
-
return normalized === 'source' || normalized.startsWith('source/')
|
|
22
|
-
})) {
|
|
23
|
-
fail('package.json files must not include source/')
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (!files.some((entry) => String(entry).replace(/^\.\//, '').includes('dist'))) {
|
|
27
|
-
fail('package.json files must include x/dist')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const dryRun = execSync('npm pack --dry-run 2>&1', { cwd: root, encoding: 'utf8' })
|
|
31
|
-
|
|
32
|
-
if (/source\/.*\.ts/.test(dryRun) || /npm notice.*source\//.test(dryRun)) {
|
|
33
|
-
fail('npm pack tarball lists source/ — TypeScript source must not ship')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!/x\/dist\/.*\.js/.test(dryRun)) {
|
|
37
|
-
fail('npm pack tarball must include x/dist/**/*.js')
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (!fs.existsSync(path.join(root, 'x/dist/index.js'))) {
|
|
41
|
-
fail('x/dist/index.js missing')
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
console.log('verify-npm-pack: ✓ no source/ in package')
|
|
45
|
-
console.log('verify-npm-pack: ✓ x/dist runtime present')
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { PublishGuardError, runPublishGuards } from './publish-guard.mjs'
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
runPublishGuards(process.cwd(), { strictDisk: false })
|
|
6
|
+
console.log('verify-publish-config: ✓ npm pack would not ship source/')
|
|
7
|
+
} catch (error) {
|
|
8
|
+
console.error(`verify-publish-config: ✗ ${error instanceof PublishGuardError ? error.message : error.message}`)
|
|
9
|
+
process.exit(1)
|
|
10
|
+
}
|
package/x/dist/index.d.ts
CHANGED
package/x/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import a from"./project/index.js";await(async()=>{await a({})})();
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
export { ensureCoreTmpEntry, isCorePackageRoot } from '../utils/helpers/core/tmp-layout';
|
|
2
|
+
export { getTmpSnapshot } from '../utils/helpers/tmp/tmp-loader';
|
|
1
3
|
export declare const core: {
|
|
2
4
|
_: Record<string, unknown>;
|
|
3
5
|
};
|
|
4
6
|
export declare const coreInit: (params: {
|
|
5
|
-
locales?: Record<string,
|
|
7
|
+
locales?: Record<string, unknown>;
|
|
6
8
|
}) => Promise<void>;
|
|
7
|
-
declare const coreLoader: (
|
|
9
|
+
declare const coreLoader: (_params?: Record<string, never>) => Promise<{
|
|
10
|
+
_: Record<string, unknown>;
|
|
11
|
+
}>;
|
|
8
12
|
export default coreLoader;
|
package/x/dist/project/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var __dirname="/home/runner/work/-xrystal-core/-xrystal-core/x/dist/project";import
|
|
1
|
+
var __dirname="/home/runner/work/-xrystal-core/-xrystal-core/x/dist/project";import w from"path";import{System as G,Configs as I,Logger as J,Events as N,Localizations as O,DtoRuntime as Q,Clients as U,Controller as V,KafkaForCore as W}from"../loader/index.js";import{Constants as X,getCore as Y,x as Z}from"../utils/index.js";import{ensureCoreTmpEntry as _,isCorePackageRoot as $}from"../utils/helpers/core/tmp-layout.js";import{getTmpSnapshot as v}from"../utils/helpers/tmp/tmp-loader.js";export{ensureCoreTmpEntry,isCorePackageRoot}from"../utils/helpers/core/tmp-layout.js";export{getTmpSnapshot}from"../utils/helpers/tmp/tmp-loader.js";export const core=Y(),coreInit=async(q)=>{const{locales:b}=q;if(b)globalThis.__LOCAL_MESSAGES__=b};let A=!1;const x=async(q={})=>{if(A)return core;const b=process.cwd();if($(b))_(b);v();try{await(await Z.load([w.join(__dirname,"..","loader","**/*.{ts,js}")],{exclude:[w.join(__dirname,"..","utils","**/class.x.{ts,js}")]})).initialize([{service:G,props:{core}},{service:I,props:{}},{service:W,props:{}},{service:J,props:{}},{service:N,props:{}},{service:O,props:{}},{service:Q,props:{}},{service:V,props:{}},{service:U,props:{}}]);A=!0;return core}catch(j){const B=j instanceof Error?j.message:String(j);console.error(`[${X.packageName} core failure]: ${B}`);throw j}};export default x;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* ONE-TIME cleanup: remove npm versions that shipped source/ in the tarball.
|
|
4
|
-
* Remove this script + the workflow step after leaked versions are gone.
|
|
5
|
-
*/
|
|
6
|
-
import { execSync } from 'node:child_process'
|
|
7
|
-
import fs from 'node:fs'
|
|
8
|
-
import path from 'node:path'
|
|
9
|
-
|
|
10
|
-
const pkgName = '@xrystal/core'
|
|
11
|
-
const root = process.cwd()
|
|
12
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8'))
|
|
13
|
-
const publishingVersion = pkg.version
|
|
14
|
-
|
|
15
|
-
function run(cmd) {
|
|
16
|
-
return execSync(cmd, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] }).trim()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function resolveVersionsToUnpublish() {
|
|
20
|
-
const fromEnv = process.env.UNPUBLISH_VERSIONS?.trim()
|
|
21
|
-
if (fromEnv) {
|
|
22
|
-
return fromEnv.split(',').map((v) => v.trim()).filter(Boolean)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let published = []
|
|
26
|
-
try {
|
|
27
|
-
const raw = run(`npm view ${pkgName} versions --json`)
|
|
28
|
-
published = JSON.parse(raw)
|
|
29
|
-
if (!Array.isArray(published)) published = [published]
|
|
30
|
-
} catch {
|
|
31
|
-
console.log('unpublish-leaked: no published versions found on registry')
|
|
32
|
-
return []
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return published
|
|
36
|
-
.filter((v) => v !== publishingVersion)
|
|
37
|
-
.slice(-3)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const versions = resolveVersionsToUnpublish()
|
|
41
|
-
if (versions.length === 0) {
|
|
42
|
-
console.log('unpublish-leaked: nothing to unpublish')
|
|
43
|
-
process.exit(0)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
console.log(`unpublish-leaked: targeting ${versions.join(', ')} (keeping ${publishingVersion} for publish)`)
|
|
47
|
-
|
|
48
|
-
for (const version of versions) {
|
|
49
|
-
try {
|
|
50
|
-
run(`npm unpublish ${pkgName}@${version} --force`)
|
|
51
|
-
console.log(`unpublish-leaked: ✓ removed ${pkgName}@${version}`)
|
|
52
|
-
} catch (error) {
|
|
53
|
-
const stderr = error.stderr?.toString?.() ?? String(error)
|
|
54
|
-
console.warn(`unpublish-leaked: ⚠ unpublish ${version} failed: ${stderr.split('\n')[0]}`)
|
|
55
|
-
try {
|
|
56
|
-
run(`npm deprecate ${pkgName}@${version} "Removed: shipped source by mistake. Upgrade to a newer release."`)
|
|
57
|
-
console.log(`unpublish-leaked: deprecated ${pkgName}@${version} as fallback`)
|
|
58
|
-
} catch {
|
|
59
|
-
console.warn(`unpublish-leaked: ⚠ deprecate also failed for ${version}`)
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|