|
| 1 | +set quiet |
| 2 | + |
| 3 | +import? '../sdk-codegen/utils.just' |
| 4 | + |
| 5 | +# make locally installed binaries available throughout the tree without a longer specifier |
| 6 | +# this is useful in this file, but also depended on by webhook tests that expect to be able to call `eslint` and (I think) don't set it up correctly themselves. |
| 7 | +export PATH := `pwd` + "/node_modules/.bin:" + env('PATH') |
| 8 | + |
| 9 | +_default: |
| 10 | + just --list --unsorted |
| 11 | + |
| 12 | +# this uses positional-args so that mixed quoted and unquoted arguments |
| 13 | +# (like filtering for a certain test) work the way we expect |
| 14 | +# ⭐ run unit tests |
| 15 | +[positional-arguments] |
| 16 | +test *args: install build |
| 17 | + mocha "$@" |
| 18 | + |
| 19 | +# try to compile the example TS file to make sure exports work |
| 20 | +types-test: build |
| 21 | + tsc --build types/test |
| 22 | + |
| 23 | +# run full integration tests by installing a bunch of packages and starting servers (slow) |
| 24 | +integrations-test: build |
| 25 | + RUN_INTEGRATION_TESTS=1 mocha test/Integration.spec.ts |
| 26 | + |
| 27 | +# run the full test suite; you probably want `test` |
| 28 | +ci-test: install test types-test integrations-test |
| 29 | + |
| 30 | +_build mode packageType: install |
| 31 | + mkdir -p {{ mode }} |
| 32 | + tsc -p tsconfig.{{ mode }}.json |
| 33 | + echo '{"type":"{{ packageType }}"}' > {{ mode }}/package.json |
| 34 | + |
| 35 | +[private] |
| 36 | +build-esm: (_build "esm" "module") |
| 37 | + |
| 38 | +[private] |
| 39 | +build-cjs: (_build "cjs" "commonjs") |
| 40 | + |
| 41 | +# generate CJS and ESM versions of the package; mostly used as a pre-req for other steps |
| 42 | +build: build-esm build-cjs |
| 43 | + |
| 44 | +# ⭐ run style checks, fixing issues if possible |
| 45 | +lint: (lint-check "--fix") |
| 46 | + |
| 47 | +# run style checks without changing anything |
| 48 | +lint-check *args: install |
| 49 | + eslint --ext .js,.ts . {{ args }} |
| 50 | + |
| 51 | +# reinstall dependencies, if needed |
| 52 | +install: |
| 53 | + yarn {{ if is_dependency() == "true" { "--silent" } else { "" } }} |
| 54 | + |
| 55 | +[no-exit-message] |
| 56 | +[private] |
| 57 | +prettier *args: install |
| 58 | + # all the project-relevant JS code |
| 59 | + prettier "{src,examples,scripts,test,types}/**/*.{ts,js}" {{ args }} |
| 60 | + |
| 61 | +# ⭐ format all files |
| 62 | +format: (prettier "--write --loglevel silent") _update-api-version |
| 63 | + |
| 64 | +# verify formatting of files (without changes) |
| 65 | +format-check: (prettier "--check") |
| 66 | + |
| 67 | +# propagate automatic changes; should be run after generation |
| 68 | +# in practice, that means it runs after formatting, since that's the only recipe that the generator calls |
| 69 | +_update-api-version: |
| 70 | + ./scripts/updateAPIVersion.js |
| 71 | + |
| 72 | +# called by tooling |
| 73 | +[private] |
| 74 | +update-version version: |
| 75 | + echo "{{ version }}" > VERSION |
| 76 | + perl -pi -e 's|"version": "[.\-\d\w]+"|"version": "{{ version }}"|' package.json |
| 77 | + perl -pi -e "s|Stripe.PACKAGE_VERSION = '[.\-\d\w]+'|Stripe.PACKAGE_VERSION = '{{ version }}'|" src/stripe.core.ts |
| 78 | + |
| 79 | +# remove build artifacts |
| 80 | +clean: |
| 81 | + rm -rf ./node_modules/.cache ./esm ./cjs |
0 commit comments