A plugin skeleton that utilizes nps
to fully automate the release process.
Optimized for development in Visual Studio Code.
- Follow all steps below, but with a throwaway plugin name and
npm unpublish
+ delete the github repository after you've tried out the process
git clone https://github.com/fkleuver/aurelia-plugin-skeleton-ts-webpack your-plugin-name
- Replace all "aurelia-plugin-skeleton-ts-webpack" with the name of your plugin/repo
- Rename the
aurelia-plugin-skeleton-ts-webpack.ts
file to the name of your plugin - Update the
description
,keywords
,author
,bugs.url
andrepository.url
fields inpackage.json
- Update the
LICENSE
file with your own name
- Create a new repository on github
- (optional) remove the .git directory and initialize a fresh, new git repo without my commit history
- Set the remote tracking branch and push your master branch
- Run
npm run ghpages-setup
(see bottom of package-scripts.js for clarification on what that does)
yarn install
(ornpm install
, but I find yarn to give less friction overall)- Reopen the folder (if you're working in vs code) to properly initialize typescript
There are two ways to test your code, and you can (as I often do) run them simultaneously. This gives you plenty of means to develop your plugin in small, simple steps while constantly being able to test and verify your code.
From the project root:
-
npm run test-watch
to start karma (will run Chrome in Headless mode) -
Go to the
coverage
folder and openindex.html
in a browser to see your test coverage (refresh to update)
Tip: the code coverage page allows you to drill down into your code and see exactly which parts are covered by tests. Great for helping you to decide what tests you should write.
Also from the project root, from another command prompt:
npm run demo-dev
to start the webpack dev server for the demo page
While the demo page is first and foremost meant to be a live running example where users can see the plugin in action, it's also useful as a manual end-to-end test and to quickly try some new stuff.
- Add a file and write some code
- Add a file with the same name +
.spec
undertest/unit
You get the idea :-)
npm run test-debug
(you'll now get more verbose logging output in the console)
- In Chrome, press the
DEBUG
button to open the debugging window
Here you can see any script errors in the console
- Start the VS Code debugger and pick "Attach Karma Chrome"
- Attach to the DEBUG window
- Set a breakpoint
- Refresh the DEBUG window in chrome
- Your breakpoint should get hit
A few notes on debugging in VS Code:
Debugging in VS Code can be a bit quirky sometimes, especially with async code. The problem mainly has to do with webpack and source maps. We've recently had 4.0 and the plugin ecosystem hasn't quite caught up yet.
When you can't step into, over or out of certain code (e.g. the debugger jumps to the start of a file and stays there) that doesn't mean you can't debug that code. You'll just need to set a breakpoint closer to the part you want to inspect.
Source maps also don't seem to update when you change code in debug mode, so after changing a few lines of code you may find the debugger completely refusing to co-operate. Just restart npm run test-debug
, refresh again and it should work.
- If you don't have an account already - create one, and authenticate locally so that the release script can
npm publish
npm run test
to run all tests oncenpm run lint
to get surprised with what typescript thinks of your codenpm run demo-prod
to double check the demo still works
There is a patch
, minor
and major
variant of the release script. The examples below will use patch
, but the same applies for the other two.
Please make sure the working directory is "clean" in git's terms.
A dry run will execute the normal process of running tests and building your code, but will not commit, push to git or publish to npm. It will make modifications to your local files (the build output and package.json). These are easy to undo however.
npm run release-patch-dry
Verify that no crazy things would happen, and undo the changes.
npm run release-patch
That's equivalent to the following (with node_modules subpaths and TS_NODE_PROJECT assignment omitted for brevity):
karma start --single-run=true --auto-watch=false --browsers=ChromeHeadless --transpile-only=true --no-info=true --coverage=true --tsconfig=configs/tsconfig-test.json
tslint --project configs/tsconfig-build.json
rimraf dist
- concurrently:
tsc --project configs/tsconfig-build-amd.json
tsc --project configs/tsconfig-build-commonjs.json
tsc --project configs/tsconfig-build-es2017.json
tsc --project configs/tsconfig-build-es2015.json
tsc --project configs/tsconfig-build-native-modules.json
tsc --project configs/tsconfig-build-system.json
npm --no-git-tag-version version patch
(bumps the version number in package.json)git add package.json dist
standard-version --first-release --commit-all
(adds changes to changelog, git tags to current version and commits those changes)git push --follow-tags origin master
npm publish
npm run ghpages
That's equivalent to the following:
git checkout gh-pages
git merge master --no-edit
rimraf *.bundle.js
webpack --env.production
git add index.html *.bundle.js
git commit -m "doc(demo): build demo"
git push
git checkout master
And there you have it, one-click release :-)