Skip to content

Commit

Permalink
fix: bug in assemble indexes (#73)
Browse files Browse the repository at this point in the history
* fix: bug in assemble indexes
* Add better tests to ensure working correctly

* feat: move deps to optional
* Only needed if using the parkin CLI, which is not even deployed yet
* Add resetPkg script to better handle version when publishing to NPM
  • Loading branch information
lancetipton authored Jan 2, 2024
1 parent 3221a92 commit cca7d38
Show file tree
Hide file tree
Showing 9 changed files with 322 additions and 29 deletions.
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
"node": ">= 16.0.0"
},
"scripts": {
"prebuild": "pnpm format && pnpm test && pnpm parkin",
"build": "pnpm build:es && pnpm build:copy && pnpm build:cli",
"build:es": "node --enable-source-maps -r esbuild-register configs/build.config.ts",
"build:copy": "rimraf docs/parkin && cp -R build/cjs docs/parkin",
Expand All @@ -58,15 +57,16 @@
"docs:deploy": "pnpm build && gh-pages -d docs",
"docs:serve": "cd ./docs && serve .",
"docs": "pnpm docs:serve",
"json:reset": "git checkout ./package.json",
"json:reset": "node --no-warnings --enable-source-maps --loader esbuild-register/loader -r esbuild-register scripts/resetPkg.ts",
"json:rm": "pnpm json:rm:dev && pnpm json:rm:deps && pnpm json:rm:bin",
"json:rm:bin": "echo \"$(cat package.json | jqn 'delete $.bin;JSON.stringify($, null, 2)')\" > package.json",
"json:rm:dev": "echo \"$(cat package.json | jqn 'delete $.devDependencies;JSON.stringify($, null, 2)')\" > package.json",
"json:rm:deps": "echo \"$(cat package.json | jqn 'delete $.dependencies;JSON.stringify($, null, 2)')\" > package.json",
"format:eslint": "eslint --config ./configs/eslintrc.config.js . --fix --quiet",
"format:prettier": "prettier --config ./configs/prettier.config.js --ignore-path .eslintignore --write '**/*.{js,jsx}'",
"format": "pnpm format:prettier && pnpm format:eslint",
"prepack": "pnpm json:rm",
"prebuild": "pnpm format && pnpm test && pnpm parkin",
"postbuild": "pnpm json:rm",
"postpublish": "pnpm json:reset",
"parkin": "node --no-warnings --loader esbuild-register/loader -r esbuild-register src/bin/parkin.ts --features ./features --defs ./defs --world ./world.ts --root ./parkin",
"test": "NODE_ENV=test jest --detectOpenHandles --no-cache --verbose --config=./configs/jest.config.js --maxWorkers=50%",
Expand All @@ -75,23 +75,24 @@
"view:reports": "open reports/coverage/lcov-report/index.html"
},
"optionalDependencies": {
"esbuild": ">=0.18.0",
"esbuild-register": ">=3.0.0"
},
"dependencies": {
"@keg-hub/args-parse": "10.0.1",
"@keg-hub/cli-utils": "0.8.0",
"esbuild": "0.19.8",
"esbuild-register": "3.5.0"
"esbuild": ">=0.18.0",
"esbuild-register": ">=3.0.0"
},
"dependencies": {},
"devDependencies": {
"@jgoz/esbuild-plugin-typecheck": "3.1.0",
"@keg-hub/args-parse": "10.0.1",
"@keg-hub/cli-utils": "0.8.0",
"@keg-hub/jsutils": "9.10.0",
"@storybook/expect": "28.1.3-5",
"@types/jest": "29.5.10",
"@types/node": "20.10.2",
"@typescript-eslint/parser": "6.13.1",
"es-jest": "2.1.0",
"esbuild": "0.19.8",
"esbuild-register": "3.5.0",
"esbuild-plugin-d.ts": "1.1.0",
"esbuild-plugin-path-alias": "1.0.7",
"esbuild-plugins-node-modules-polyfill": "1.6.1",
Expand Down
40 changes: 37 additions & 3 deletions pnpm-lock.yaml

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

46 changes: 46 additions & 0 deletions scripts/resetPkg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { promisify } from 'util'
import { exec } from 'child_process'


const dirname = path.dirname(fileURLToPath(import.meta.url))
const cmdExec = promisify(exec)
const rootPath = path.join(dirname, `../`)


/**
* Executes a command in the docs directory
* @function
*
* @param {string} cmd - Command to be run
*
* @returns {Promise} - resolves to response from cmdExec method
*/
const runCmd = async cmd => {
return await cmdExec(cmd, { cwd: rootPath })
}

/**
* Gets the current package.json version
* Then resets the package.json in git
* Finally updates the package.json back to the version it was before git checkout
*/
const resetPkg = async () => {
const oldv = process.env.npm_package_version
await runCmd(`git checkout ./package.json`)
await runCmd(`pnpm version ${oldv} --no-git-tag-version --allow-same-version --no-commit-hooks`)
await runCmd(`git add ./package.json`)

try {
const resp = await runCmd(`git commit -m "Update version to \"${oldv}\""`)
console.log(resp)
}
catch(err){
if(err.stdout.includes(`not staged`)) return
throw err
}
}


resetPkg()
Loading

0 comments on commit cca7d38

Please sign in to comment.