Skip to content

Commit 5189d74

Browse files
authoredDec 30, 2023
chore: Rework publish script (#5240)
* Start reworking publish script * Nearly done * All code copied * Fix missing dependencies * fix: Script running successfully * Add scripts folder to root tsconfig include * Add tag option to CI * Mark root as ESM, explicitly add CJS to packages * Remove ts-node
1 parent 72c7ed6 commit 5189d74

26 files changed

+625
-1128
lines changed
 

‎.github/workflows/ci.yml

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: ci
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: override release tag
8+
required: false
49
push:
510
branches: ['main', 'alpha', 'beta', 'rc']
611

@@ -27,12 +32,17 @@ jobs:
2732
cache: pnpm
2833
- name: Install dependencies
2934
run: pnpm install --frozen-lockfile
30-
- run: |
35+
- name: Run Tests
36+
run: pnpm run test:ci
37+
- name: Publish
38+
run: |
3139
git config --global user.name 'Tanner Linsley'
3240
git config --global user.email 'tannerlinsley@users.noreply.github.com'
41+
npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
3342
pnpm run cipublish
3443
env:
3544
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
3645
GH_TOKEN: ${{ secrets.GH_TOKEN }}
3746
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3847
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
48+
TAG: ${{ inputs.tag }}

‎babel.config.js ‎babel.config.cjs

File renamed without changes.

‎package.json

+11-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"private": true,
44
"repository": "https://github.com/tanstack/table.git",
55
"packageManager": "pnpm@8.12.1",
6+
"type": "module",
67
"scripts": {
78
"clean": "pnpm --filter \"./packages/**\" run clean",
89
"preinstall": "node -e \"if(process.env.CI == 'true') {console.log('Skipping preinstall...'); process.exit(1)}\" || npx -y only-allow pnpm",
@@ -15,8 +16,7 @@
1516
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all",
1617
"dev": "pnpm run watch",
1718
"prettier": "prettier \"packages/*/{src/**,examples/**/src/**}.{md,js,jsx,ts,tsx,json}\" --write",
18-
"cipublish": "ts-node scripts/publish.ts",
19-
"cipublishforce": "CI=true pnpm run cipublish",
19+
"cipublish": "node scripts/publish.js",
2020
"test:pr": "nx affected --targets=test:lib,test:types,build --exclude=examples/**",
2121
"test:ci": "nx run-many --targets=test:lib,test:types,build --exclude=examples/**"
2222
},
@@ -29,7 +29,7 @@
2929
"@babel/preset-env": "^7.21.5",
3030
"@babel/preset-react": "^7.18.6",
3131
"@babel/preset-typescript": "^7.21.5",
32-
"@commitlint/parse": "^16.2.1",
32+
"@commitlint/parse": "^18.4.3",
3333
"@faker-js/faker": "^8.3.1",
3434
"@rollup/plugin-babel": "^6.0.3",
3535
"@rollup/plugin-commonjs": "^25.0.7",
@@ -39,17 +39,23 @@
3939
"@testing-library/react": "^12.1.2",
4040
"@testing-library/react-hooks": "^7.0.2",
4141
"@tsconfig/svelte": "^3.0.0",
42+
"@types/current-git-branch": "^1.1.6",
43+
"@types/git-log-parser": "^1.2.3",
44+
"@types/jsonfile": "^6.1.4",
4245
"@types/luxon": "^2.3.1",
4346
"@types/node": "^18.15.10",
4447
"@types/react": "^18.2.45",
4548
"@types/react-dom": "^18.2.18",
4649
"@types/semver": "^7.3.10",
50+
"@types/stream-to-array": "^2.3.3",
4751
"axios": "^0.26.1",
4852
"babel-plugin-transform-async-to-promises": "^0.8.18",
53+
"chalk": "^5.3.0",
4954
"concurrently": "^7.1.0",
5055
"current-git-branch": "^1.1.0",
5156
"git-log-parser": "^1.2.0",
5257
"jsdom": "^21.1.1",
58+
"jsonfile": "^6.1.0",
5359
"luxon": "^2.3.2",
5460
"nx": "^17.2.7",
5561
"prettier": "^3.0.3",
@@ -61,10 +67,11 @@
6167
"rollup-plugin-svelte": "^7.1.0",
6268
"rollup-plugin-terser": "^7.0.2",
6369
"rollup-plugin-visualizer": "^5.6.0",
70+
"semver": "^7.5.4",
6471
"solid-js": "^1.6.2",
6572
"stream-to-array": "^2.3.0",
6673
"svelte": "^3.49.0",
67-
"ts-node": "^10.9.2",
74+
"type-fest": "^4.8.3",
6875
"typescript": "5.2.2",
6976
"vitest": "^0.29.3",
7077
"vue": "^3.2.33"

‎packages/match-sorter-utils/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"type": "github",
2929
"url": "https://github.com/sponsors/kentcdodds"
3030
},
31+
"type": "commonjs",
3132
"module": "build/lib/index.esm.js",
3233
"main": "build/lib/index.js",
3334
"types": "build/lib/index.d.ts",

‎packages/match-sorter-utils/rollup.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import { defineConfig } from 'rollup'
4-
import { buildConfigs } from '../../scripts/getRollupConfig.mjs'
4+
import { buildConfigs } from '../../scripts/getRollupConfig.js'
55

66
export default defineConfig(
77
buildConfigs({

‎packages/react-table-devtools/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "github",
2323
"url": "https://github.com/sponsors/tannerlinsley"
2424
},
25+
"type": "commonjs",
2526
"module": "build/lib/index.esm.js",
2627
"main": "build/lib/index.js",
2728
"types": "build/lib/index.d.ts",

‎packages/react-table-devtools/rollup.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import { defineConfig } from 'rollup'
4-
import { buildConfigs } from '../../scripts/getRollupConfig.mjs'
4+
import { buildConfigs } from '../../scripts/getRollupConfig.js'
55

66
export default defineConfig(
77
buildConfigs({

‎packages/react-table/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "github",
2323
"url": "https://github.com/sponsors/tannerlinsley"
2424
},
25+
"type": "commonjs",
2526
"module": "build/lib/index.esm.js",
2627
"main": "build/lib/index.js",
2728
"types": "build/lib/index.d.ts",

‎packages/react-table/rollup.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import { defineConfig } from 'rollup'
4-
import { buildConfigs } from '../../scripts/getRollupConfig.mjs'
4+
import { buildConfigs } from '../../scripts/getRollupConfig.js'
55

66
export default defineConfig(
77
buildConfigs({

‎packages/solid-table/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "github",
2323
"url": "https://github.com/sponsors/tannerlinsley"
2424
},
25+
"type": "commonjs",
2526
"module": "build/lib/index.esm.js",
2627
"main": "build/lib/index.js",
2728
"types": "build/lib/index.d.ts",

‎packages/solid-table/rollup.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import { defineConfig } from 'rollup'
4-
import { buildConfigs } from '../../scripts/getRollupConfig.mjs'
4+
import { buildConfigs } from '../../scripts/getRollupConfig.js'
55

66
export default defineConfig(
77
buildConfigs({

‎packages/svelte-table/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "github",
2323
"url": "https://github.com/sponsors/tannerlinsley"
2424
},
25+
"type": "commonjs",
2526
"module": "build/lib/index.esm.js",
2627
"main": "build/lib/index.js",
2728
"types": "build/lib/index.d.ts",

‎packages/svelte-table/rollup.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import { defineConfig } from 'rollup'
4-
import { buildConfigs } from '../../scripts/getRollupConfig.mjs'
4+
import { buildConfigs } from '../../scripts/getRollupConfig.js'
55

66
export default defineConfig(
77
buildConfigs({

‎packages/table-core/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"type": "github",
2525
"url": "https://github.com/sponsors/tannerlinsley"
2626
},
27+
"type": "commonjs",
2728
"module": "build/lib/index.esm.js",
2829
"main": "build/lib/index.js",
2930
"types": "build/lib/index.d.ts",

‎packages/table-core/rollup.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import { defineConfig } from 'rollup'
4-
import { buildConfigs } from '../../scripts/getRollupConfig.mjs'
4+
import { buildConfigs } from '../../scripts/getRollupConfig.js'
55

66
export default defineConfig(
77
buildConfigs({

‎packages/vue-table/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"type": "github",
2323
"url": "https://github.com/sponsors/tannerlinsley"
2424
},
25+
"type": "commonjs",
2526
"module": "build/lib/index.esm.js",
2627
"main": "build/lib/index.js",
2728
"types": "build/lib/index.d.ts",

‎packages/vue-table/rollup.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import { defineConfig } from 'rollup'
4-
import { buildConfigs } from '../../scripts/getRollupConfig.mjs'
4+
import { buildConfigs } from '../../scripts/getRollupConfig.js'
55

66
export default defineConfig(
77
buildConfigs({

‎pnpm-lock.yaml

+89-389
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

‎scripts/config.mjs ‎scripts/config.js

+7-32
Original file line numberDiff line numberDiff line change
@@ -10,77 +10,52 @@ import { fileURLToPath } from 'node:url'
1010
export const packages = [
1111
{
1212
name: '@tanstack/table-core',
13-
packageDir: 'table-core',
14-
srcDir: 'src',
13+
packageDir: 'packages/table-core',
1514
},
1615
{
1716
name: '@tanstack/react-table',
18-
packageDir: 'react-table',
19-
srcDir: 'src',
20-
dependencies: ['@tanstack/table-core'],
17+
packageDir: 'packages/react-table',
2118
},
2219
{
2320
name: '@tanstack/solid-table',
24-
packageDir: 'solid-table',
25-
srcDir: 'src',
26-
dependencies: ['@tanstack/table-core'],
21+
packageDir: 'packages/solid-table',
2722
},
2823
{
2924
name: '@tanstack/vue-table',
30-
packageDir: 'vue-table',
31-
srcDir: 'src',
32-
dependencies: ['@tanstack/table-core'],
25+
packageDir: 'packages/vue-table',
3326
},
3427
{
3528
name: '@tanstack/svelte-table',
36-
packageDir: 'svelte-table',
37-
srcDir: 'src',
38-
dependencies: ['@tanstack/table-core'],
29+
packageDir: 'packages/svelte-table',
3930
},
4031
{
4132
name: '@tanstack/react-table-devtools',
42-
packageDir: 'react-table-devtools',
43-
srcDir: 'src',
44-
peerDependencies: ['@tanstack/react-table'],
33+
packageDir: 'packages/react-table-devtools',
4534
},
4635
{
4736
name: '@tanstack/match-sorter-utils',
48-
packageDir: 'match-sorter-utils',
49-
srcDir: 'src',
37+
packageDir: 'packages/match-sorter-utils',
5038
},
5139
]
5240

53-
export const latestBranch = 'main'
54-
5541
/**
5642
* Contains config for publishable branches.
5743
* @type {Record<string, import('./types').BranchConfig>}
5844
*/
5945
export const branchConfigs = {
6046
main: {
6147
prerelease: false,
62-
ghRelease: true,
6348
},
6449
next: {
6550
prerelease: true,
66-
ghRelease: true,
6751
},
6852
beta: {
6953
prerelease: true,
70-
ghRelease: true,
7154
},
7255
alpha: {
7356
prerelease: true,
74-
ghRelease: true,
7557
},
7658
}
7759

7860
const __dirname = fileURLToPath(new URL('.', import.meta.url))
7961
export const rootDir = resolve(__dirname, '..')
80-
81-
export const examplesDirs = [
82-
'examples/react',
83-
'examples/solid',
84-
'examples/svelte',
85-
'examples/vue',
86-
]

‎scripts/getRollupConfig.mjs ‎scripts/getRollupConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import size from 'rollup-plugin-size'
99
import replace from '@rollup/plugin-replace'
1010
import { nodeResolve } from '@rollup/plugin-node-resolve'
1111
import svelte from 'rollup-plugin-svelte'
12-
import { rootDir } from './config.mjs'
12+
import { rootDir } from './config.js'
1313

1414
/** @param {'development' | 'production'} type */
1515
const forceEnvPlugin = type =>
@@ -20,7 +20,7 @@ const forceEnvPlugin = type =>
2020
})
2121

2222
const babelPlugin = babel({
23-
configFile: resolve(rootDir, 'babel.config.js'),
23+
configFile: resolve(rootDir, 'babel.config.cjs'),
2424
babelHelpers: 'bundled',
2525
exclude: /node_modules/,
2626
extensions: ['.ts', '.tsx'],

‎scripts/publish.js

+482
Large diffs are not rendered by default.

‎scripts/publish.ts

-663
This file was deleted.

‎scripts/tsconfig.json

-20
This file was deleted.

‎scripts/types.ts ‎scripts/types.d.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,26 @@ export type AuthorOrCommitter = {
2020
}
2121

2222
export type Parsed = {
23-
type: string
23+
type: string | null
2424
scope?: string | null
2525
subject: string
2626
merge?: null
2727
header: string
2828
body?: null
2929
footer?: null
30-
notes?: null[] | null
31-
references?: null[] | null
32-
mentions?: null[] | null
30+
notes?: Array<null> | null
31+
references?: Array<null> | null
32+
mentions?: Array<null> | null
3333
revert?: null
3434
raw: string
3535
}
3636

3737
export type Package = {
3838
name: string
3939
packageDir: string
40-
srcDir: string
41-
dependencies?: string[]
42-
peerDependencies?: string[]
4340
}
4441

4542
export type BranchConfig = {
4643
prerelease: boolean
47-
ghRelease: boolean
44+
previousVersion?: boolean
4845
}

‎tsconfig.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
"declaration": true,
1313
"esModuleInterop": true,
1414
"skipLibCheck": true,
15-
"baseUrl": "."
15+
"baseUrl": ".",
16+
"allowJs": true,
17+
"checkJs": true
1618
},
17-
"include": ["prettier.config.js"]
19+
"include": ["prettier.config.cjs", "scripts"]
1820
}

0 commit comments

Comments
 (0)
Please sign in to comment.