Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 348c27a

Browse files
committed
chore: prepare for first release
1 parent 39cebd4 commit 348c27a

File tree

8 files changed

+60
-9
lines changed

8 files changed

+60
-9
lines changed

.github/workflows/npm-publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: npm-publish
2+
on:
3+
workflow_dispatch:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish:
9+
# only allow on main or tags
10+
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') }}
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v2
15+
- name: Use Node.js
16+
uses: actions/setup-node@v2
17+
# We're using npm to publish due to: https://github.com/yarnpkg/yarn/issues/5779
18+
- run: npm install
19+
- id: publish
20+
uses: JS-DevTools/[email protected]
21+
with:
22+
token: ${{ secrets.NPM_TOKEN }}
23+
dry-run: ${{ github.event.action != 'published' }}
24+
- if: steps.publish.outputs.type != 'none'
25+
run: |
26+
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/coverage
33
/dist
44
yarn-error.log
5+
/canva-public-dependency-tree-*.tgz

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
# dependency-tree
1+
# @canva-public/dependency-tree
22

3-
![build](https://github.com/canva-public/dependency-tree/actions/workflows/node.js.yml/badge.svg)
3+
[![build](https://github.com/canva-public/dependency-tree/actions/workflows/node.js.yml/badge.svg)](https://github.com/canva-public/dependency-tree/actions/workflows/node.js.yml)
4+
[![npm](https://img.shields.io/npm/v/@canva-public/dependency-tree.svg)](https://www.npmjs.com/package/@canva-public/dependency-tree)
45

56
This package can create a dependency tree from a given set of files/folders.
67
The nodes of the tree are files and the edges are file -> file dependencies.
@@ -42,3 +43,10 @@ const directOrTransitiveDependencies = DependencyTree.getDependencies(
4243

4344
- Visualisation of (epxlicit and implicit) in-code dependencies
4445
- Identifying build targets that need to be regenerated based on affected code
46+
47+
## Releasing
48+
49+
- Bump the version of `package.json` to a meaningful version for the changes since the last release (we follow semver).
50+
- To do a dry-run of the release and what would go out in the package you can manually execute the [npm-publish](https://github.com/canva-public/dependency-tree/actions/workflows/npm-publish.yml) workflow on the `main` branch. It will do a dry-run publish (not actually publish the new version).
51+
- Draft a new release in the github project - please use a tag named `vX.X.X` (where `X.X.X` is the new to-be-releases semver of the package - please add as many detail as possible to the release description.
52+
- Once you're ready, `Publish` the release. Publishing will trigger the [npm-publish](https://github.com/canva-public/dependency-tree/actions/workflows/npm-publish.yml) workflow on the tag and do the actual publish to npm.

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
44
testPathIgnorePatterns: [
5-
'/dist',
5+
'/dist/',
66
'/node_modules/',
77
'/fixtures/',
88
'.eslintrc.js',

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
2-
"name": "@canva/dependency-tree",
3-
"version": "2.4.3",
2+
"name": "@canva-public/dependency-tree",
3+
"version": "2.4.4",
44
"description": "Calculates a dependency tree for set of files",
55
"main": "dist/index.js",
66
"author": "Canva Pty Ltd",
77
"license": "MIT",
8+
"files": [
9+
"dist"
10+
],
811
"repository": {
912
"type": "git",
1013
"url": "git+ssh://[email protected]/canva-public/depdendency-tree.git"
@@ -17,13 +20,13 @@
1720
],
1821
"scripts": {
1922
"prettier": "prettier --write .",
20-
"prepare": "rimraf dist/ && tsc",
23+
"prepack": "tsc --declarationDir dist --declaration",
24+
"prepare": "rm -rf ./dist",
2125
"eslint": "eslint . --ext .js,.jsx,.ts,.tsx",
2226
"pretest": "prettier --check . && yarn eslint",
2327
"test": "jest --ci --coverage",
2428
"test:watch": "jest --watch --notify"
2529
},
26-
"private": true,
2730
"dependencies": {
2831
"acorn": "^8.0.4",
2932
"builtin-modules": "^3.2.0",
@@ -38,6 +41,7 @@
3841
"lodash.escaperegexp": "^4.1.2",
3942
"lodash.memoize": "^4.1.2",
4043
"memoize-fs": "^2.2.0",
44+
"pkginfo": "^0.4.1",
4145
"xml2js": "^0.4.23"
4246
},
4347
"devDependencies": {

src/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
import * as createDebug from 'debug';
44

5-
export const debug = createDebug('@canva/dependency-tree');
5+
export const debug = createDebug('@canva-public/dependency-tree');

src/processors/typescript.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ import { DependencyTree, FileToDeps, Path } from '../';
1010
import { FileProcessor } from '../file_processor';
1111
import { debug as logger } from '../logger';
1212
import memoize = require('lodash.memoize');
13-
import { name, version } from '../../package.json';
13+
14+
// we can't use the simple
15+
// import { name, version } from '../../package.json';
16+
// here as during the build phase TS then nests outputs in the dist dir
17+
// in order to include the package.json as a parent
18+
// @ts-expect-error pkinfo does not come with type defs and output is variable
19+
import * as pkginfo from 'pkginfo';
20+
const { name, version } = pkginfo.read(module).package;
1421

1522
// this memoizes function invocations with a cache on disk so caching works across invocations of
1623
// the script, not just the function.

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,6 +3761,11 @@ pkg-dir@^4.2.0:
37613761
dependencies:
37623762
find-up "^4.0.0"
37633763

3764+
pkginfo@^0.4.1:
3765+
version "0.4.1"
3766+
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.1.tgz#b5418ef0439de5425fc4995042dced14fb2a84ff"
3767+
integrity sha1-tUGO8EOd5UJfxJlQQtztFPsqhP8=
3768+
37643769
posix-character-classes@^0.1.0:
37653770
version "0.1.1"
37663771
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"

0 commit comments

Comments
 (0)