Skip to content

Commit

Permalink
added package setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
DuncanMcPherson committed Dec 31, 2023
1 parent 9c94251 commit f5d8f8c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
path: ~/.npm
key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }}
- run: npm ci
- run: npm run buildpackage
- run: npm publish
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.map
*.spec.*
setup-package.*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
"name": "@ez-budgets/karma-test-utils",
"version": "0.0.1",
"version": "0.0.2",
"description": "",
"main": "index.js",
"main": "dist/index.js",
"scripts": {
"test": "jasmine",
"prepare": "husky install"
"prepare": "husky install",
"prepublish": "npm pack",
"prepack": "npm run setup-package",
"setup-package": "node dist/setup-package.js",
"presetup-package": "npm run build",
"build": "tsc"
},
"repository": {
"type": "git",
Expand Down
15 changes: 15 additions & 0 deletions src/setup-package.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import fs from "fs";
import path from "path";

function main() {
const sourcePath = path.join(__dirname, "..", "package.json");
const source = fs.readFileSync(sourcePath).toString('utf-8');
const sourceObj = JSON.parse(source);

sourceObj.scripts = {};
sourceObj.devDependencies = {};
if (sourceObj.main.startsWith("dist/")) {
sourceObj.main = sourceObj.main.slice(5);
}
fs.writeFileSync(__dirname + "/package.json", Buffer.from(JSON.stringify(sourceObj, null, 2), "utf-8"));
}
9 changes: 7 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
"allowJs": true,
"sourceMap": true,
"rootDir": "./src",
"outDir": "dist",
"strict": true, /* Enable all strict type-checking options. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
}
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */
},
"include": ["src/**/*"],
"exclude": [
"**/*.spec.*"
]
}

0 comments on commit f5d8f8c

Please sign in to comment.