Skip to content

Commit

Permalink
setup publint and package.json fixes
Browse files Browse the repository at this point in the history
fixes #130
  • Loading branch information
QuentinRoy committed Nov 22, 2023
1 parent f13a3d9 commit f98c61c
Show file tree
Hide file tree
Showing 10 changed files with 199 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,7 @@ overrides:
['error', { requireReturnType: false, requireParamType: false }]
- files:
- 'packages/**/bin/**/*@(.mjs|.js|.ts|.cjs)'
- 'scripts/**/*@(.mjs|.js|.ts|.cjs)'
- 'packages/**/scripts/**/*@(.mjs|.js|.ts|.cjs)'
env:
node: true
30 changes: 30 additions & 0 deletions .github/workflows/node.js.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,33 @@ jobs:
${{ runner.os }}-pnpm-store-
- run: pnpm install --frozen-lockfile
- run: pnpm run lint

publint:
needs: ['build']
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node.js 20.x.x
uses: actions/setup-node@v3
with:
node-version: 20.x.x
- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install --frozen-lockfile
- run: pnpm run build-all
- run: pnpm run lint
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build-all": "pnpm -r build",
"test-all": "pnpm -r test run",
"changeset": "changeset",
"release": "pnpm -r build && changeset publish"
"release": "pnpm -r build && changeset publish",
"publint": "node ./scripts/publint.js"
},
"dependencies": {
"@changesets/cli": "^2.26.2",
Expand All @@ -18,6 +19,7 @@
"eslint-config-prettier": "9.0.0",
"eslint-plugin-import": "2.29.0",
"prettier": "3.1.0",
"publint": "^0.2.5",
"typescript": "5.3.2"
},
"packageManager": "[email protected]",
Expand Down
7 changes: 4 additions & 3 deletions packages/convert-touchstone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"node": "^20.x.x"
},
"exports": {
"default": "./dist/convert-touchstone.js",
"*": "./dist/*"
"import": {
"types": "./dist/convert-touchstone.d.ts",
"default": "./dist/convert-touchstone.js"
}
},
"types": "./dist/convert-touchstone.d.ts",
"bin": {
"lightmill-convert-touchstone": "./bin/cli.mjs"
},
Expand Down
6 changes: 6 additions & 0 deletions packages/log-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
],
"main": "./dist/main.js",
"types": "./dist/main.d.ts",
"exports": {
"import": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
}
},
"devDependencies": {
"@types/throttle-debounce": "^5.0.2",
"cross-env": "^7.0.3",
Expand Down
14 changes: 9 additions & 5 deletions packages/react-experiment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
],
"exports": {
".": {
"import": "./dist/main.js",
"types": "./dist/main.d.ts"
"import": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
}
},
"./*": {
"import": "./dist/*.js",
"types": "./dist/*.d.ts"
"import": {
"types": "./dist/*.d.ts",
"default": "./dist/*.js"
}
}
},
"main": "dist/main.js",
"main": "./dist/main.js",
"types": "./dist/main.d.ts",
"peerDependencies": {
"react": "^18.2.0"
Expand Down
6 changes: 6 additions & 0 deletions packages/runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
],
"main": "./dist/main.js",
"types": "./dist/main.d.ts",
"exports": {
"import": {
"types": "./dist/main.d.ts",
"default": "./dist/main.js"
}
},
"devDependencies": {
"cross-env": "^7.0.3",
"typescript": "5.3.2",
Expand Down
14 changes: 8 additions & 6 deletions packages/static-design/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
},
"exports": {
".": {
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./*": {
"import": "./dist/*.js",
"types": "./dist/*.d.ts"
"import": {
"types": "./dist/*.d.ts",
"default": "./dist/*.js"
}
}
},
"main": "./dist/index.js",
"types": "./dist/runner.d.ts",
"scripts": {
"test": "cross-env NODE_ENV=test vitest",
"build": "tsc -b tsconfig.build.json",
Expand Down
80 changes: 79 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions scripts/publint.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { readdir } from 'node:fs/promises';
import { spawn } from 'node:child_process';
import { parseArgs } from 'node:util';

function publint(path) {
return new Promise((resolve, reject) => {
const child = spawn('publint', [path]);
child.stdout.on('data', (data) => {
console.log(data.toString());
});

child.stderr.on('data', (data) => {
console.error(data.toString());
});

child.on('close', (code) => {
if (code !== 0) {
reject(code);
} else {
resolve(code);
}
});
});
}

async function publintAll() {
let hasError = false;
await publint('./').catch(() => {
hasError = true;
});
for (const packagePath of await readdir('./packages')) {
await publint(`./packages/${packagePath}`).catch(() => {
hasError = true;
});
}

if (hasError) {
throw new Error('publint failed');
}
}

const [path] = parseArgs({ allowPositionals: true }).positionals;

if (path == null) {
publintAll().catch(() => {
process.exit(1);
});
} else {
publint(path).catch(() => {
process.exit(1);
});
}

0 comments on commit f98c61c

Please sign in to comment.