Skip to content

Commit

Permalink
Refactor how the project is packaged and shipped.
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 committed Dec 22, 2023
1 parent e0c1c71 commit 04f2835
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
.env
node_modules/
lib/
dist/
.idea
tests_output/
test_output/
nightwatch.conf.js
nightwatch/
chromedriver-mobile/
logs/
src/utils/version.ts
1 change: 0 additions & 1 deletion dev-run.js

This file was deleted.

Empty file modified index.js
100644 → 100755
Empty file.
191 changes: 153 additions & 38 deletions package-lock.json

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

14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
"create-nightwatch": "./index.js"
},
"scripts": {
"build": "tsc",
"prepublishOnly": "tsc --outDir dist",
"create-nightwatch": "tsc && node dev-run.js",
"setVersion": "node -p \"'export const CURRENT_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/utils/version.ts",
"build": "rimraf dist && npm run setVersion && tsc",
"prepare": "npm run build",
"create-nightwatch": "npm run build && node index.js",
"esbuild": "esbuild --bundle src/index.ts --outdir=dist --platform=node --target=ES2019",
"test": "npm run build && npx nightwatch"
},
Expand All @@ -33,6 +34,7 @@
"mockery": "^2.1.0",
"nightwatch": "^3.0.1",
"nock": "^13.2.9",
"rimraf": "^5.0.5",
"typescript": "^4.7.3"
},
"dependencies": {
Expand All @@ -41,5 +43,9 @@
"axios": "^0.27.2",
"inquirer": "^8.2.4",
"minimist": "^1.2.6"
}
},
"files": [
"dist",
"index.js"
]
}
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Logger from './logger';
import minimist from 'minimist';
import suggestSimilarOption from './utils/suggestSimilar';
import {isNodeProject} from './utils';
import {CURRENT_VERSION} from './utils/version';
import axios, {AxiosResponse} from 'axios';
import {Packument} from '@npm/types';

Expand Down Expand Up @@ -125,13 +126,13 @@ export const getLatestVersion = async (): Promise<string | undefined | null> =>

export const checkCreateNightwatchVersion = async () => {
const latestVersion = await getLatestVersion();
const currentVersion = process.env.npm_package_version;
const currentVersion = CURRENT_VERSION;

if (latestVersion && currentVersion && latestVersion !== currentVersion) {
Logger.info(
`We've updated this onboarding tool: ${colors.red(currentVersion)} -> ${colors.green(
`\nWe've updated this onboarding tool: ${colors.red(currentVersion)} -> ${colors.green(
latestVersion
)}. To get the latest experience, run: ${colors.green('npm init nightwatch@latest')}\n\n`
)}.\nTo get the latest experience, run: ${colors.green('npm init nightwatch@latest')}\n\n`
);
}
};
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"target": "es6",
"moduleResolution": "node",
"sourceMap": false,
"outDir": "lib",
"outDir": "dist",
"resolveJsonModule": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
Expand Down

0 comments on commit 04f2835

Please sign in to comment.