diff --git a/.github/workflows/ci-all.yml b/.github/workflows/ci-all.yml index f5bb8b55..496d0b8d 100644 --- a/.github/workflows/ci-all.yml +++ b/.github/workflows/ci-all.yml @@ -24,9 +24,6 @@ jobs: node-version: 20.x run-build: true run-commit-lint: true - pre-test-script: | - pipx install algokit - algokit localnet start build-script: npm run build audit-script: npm run audit upload-artifact-name: puya-ts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 66747eb9..9a4ac1c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,12 +38,24 @@ jobs: with: path: artifacts - - name: Prepare @algorandfoundation/algo-ts - run: cp .releaserc.json artifacts/algo-ts/.releaserc.json - - name: Publish @algorandfoundation/algo-ts + uses: JS-DevTools/npm-publish@v3 + id: publish_algo_ts + with: + token: ${{ secrets.NPM_SECRET }} + package: artifacts/algo-ts/package.json + access: 'public' + dry-run: true + + - run: echo "type ${{ steps.publish_algo_ts.type }} name ${{ steps.publish_algo_ts.name }} version ${{ steps.publish_algo_ts.version }}" + +# - name: Update puya-ts' peer dependency on algo-ts +# run: npx tsx ../../scripts/update-algo-ts-peer-dep.ts ${{ steps.publish_algo_ts.version }} +# working-directory: artifacts/puya-ts + + - name: Publish @algorandfoundation/puya-ts run: npx semantic-release - working-directory: artifacts/algo-ts/ + env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_SECRET }} diff --git a/.releaserc.json b/.releaserc.json index 729aa572..89287d75 100644 --- a/.releaserc.json +++ b/.releaserc.json @@ -55,8 +55,8 @@ [ "@semantic-release/npm", { - "npmPublish": true, - "pkgRoot": "." + "npmPublish": false, + "pkgRoot": "artifacts/puya-ts" } ], "@semantic-release/github" diff --git a/.tstoolkitrc.ts b/.tstoolkitrc.ts index 0bf31844..370efb34 100644 --- a/.tstoolkitrc.ts +++ b/.tstoolkitrc.ts @@ -1,15 +1,20 @@ -import type { TsToolkitConfig } from "@makerx/ts-toolkit"; +import type { TsToolkitConfig } from '@makerx/ts-toolkit' const config: TsToolkitConfig = { packageConfig: { srcDir: 'src', + exportTypes: 'module', outDir: 'dist', moduleType: 'module', exports: { '.': 'index.ts', './cli': 'cli.ts', - './internal': 'internal.ts' - } - } + './internal': 'internal.ts', + }, + bin: { + 'puya-ts': 'bin/run-cli.ts', + puyats: 'bin/run-cli.ts', + }, + }, } export default config diff --git a/package-lock.json b/package-lock.json index 89821ec9..2d7b5a1c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,7 +24,7 @@ "@commitlint/config-conventional": "^19.5.0", "@makerx/eslint-config": "4.0.0", "@makerx/prettier-config": "2.0.1", - "@makerx/ts-toolkit": "^4.0.0-beta.20", + "@makerx/ts-toolkit": "^4.0.0-beta.21", "@rollup/plugin-commonjs": "28.0.0", "@rollup/plugin-json": "6.1.0", "@rollup/plugin-node-resolve": "15.3.0", @@ -47,6 +47,9 @@ "tsx": "4.19.1", "typescript": "^5.6.2", "vitest": "2.1.1" + }, + "peerDependencies": { + "@algorandfoundation/algo-ts": "0.0.1-alpha.1" } }, "../algorand-typescript-testing/dist": { @@ -1378,9 +1381,9 @@ "license": "MIT" }, "node_modules/@makerx/ts-toolkit": { - "version": "4.0.0-beta.20", - "resolved": "https://registry.npmjs.org/@makerx/ts-toolkit/-/ts-toolkit-4.0.0-beta.20.tgz", - "integrity": "sha512-faZyycGxk7lKvhm0nwy5hirwD6tVAdLLbEYh9kd13OzHuWiHPySt3ixdB2BXHDzoE65BU43h8X/pqlUNDbH4NA==", + "version": "4.0.0-beta.21", + "resolved": "https://registry.npmjs.org/@makerx/ts-toolkit/-/ts-toolkit-4.0.0-beta.21.tgz", + "integrity": "sha512-/2zTLS2cxGonnRNTHx9Q5byd+M0HJak8UxUJSbmoXUKRFpAPfLhsrXvQKtavyExtMf2a49D4QSVuIbBy5VY9Gw==", "dev": true, "license": "MIT", "dependencies": { @@ -7666,7 +7669,7 @@ }, "packages/algo-ts/dist": { "name": "@algorandfoundation/algo-ts", - "version": "1.0.0", + "version": "0.0.1-alpha.1", "dev": true, "peerDependencies": { "tslib": "^2.6.2" diff --git a/package.json b/package.json index bffbe218..82d1b184 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "build:3-build": "rollup -c --configPlugin typescript", "build:4-copy-pkg-json": "tstk copy-package-json -c", "build:5-copy-readme": "copyfiles ./README.md ./dist", - "test": "vitest run --exclude 'packages/**'", + "test": "vitest run", "test:approvals": "vitest run tests/approvals/_run.spec.ts", "test:expected-output": "vitest run tests/expected-output/_run.spec.ts", "test:coverage": "vitest run --coverage", @@ -51,7 +51,7 @@ "@commitlint/config-conventional": "^19.5.0", "@makerx/eslint-config": "4.0.0", "@makerx/prettier-config": "2.0.1", - "@makerx/ts-toolkit": "^4.0.0-beta.20", + "@makerx/ts-toolkit": "^4.0.0-beta.21", "@rollup/plugin-commonjs": "28.0.0", "@rollup/plugin-json": "6.1.0", "@rollup/plugin-node-resolve": "15.3.0", @@ -83,5 +83,8 @@ "glob": "^11.0.0", "polytype": "^0.17.0", "zod": "^3.23.8" + }, + "peerDependencies": { + "@algorandfoundation/algo-ts": "0.0.1-alpha.1" } } diff --git a/packages/algo-ts/package.json b/packages/algo-ts/package.json index 4418d327..5ad38ec8 100644 --- a/packages/algo-ts/package.json +++ b/packages/algo-ts/package.json @@ -1,6 +1,6 @@ { "name": "@algorandfoundation/algo-ts", - "version": "1.0.0", + "version": "0.0.1-alpha.1", "description": "", "main": "index.js", "types": "src/index.ts", diff --git a/rollup.config.ts b/rollup.config.ts index d0d02c09..c6827373 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -9,6 +9,7 @@ const config: RollupOptions = { index: 'src/index.ts', cli: 'src/cli.ts', internal: 'src/internal.ts', + 'bin/run-cli': 'src/bin/run-cli.ts', }, output: [ { @@ -21,7 +22,7 @@ const config: RollupOptions = { }, ], treeshake: { - moduleSideEffects: false, + moduleSideEffects: true, propertyReadSideEffects: false, }, external: [/node_modules/, /tslib/], diff --git a/scripts/update-algo-ts-peer-dep.ts b/scripts/update-algo-ts-peer-dep.ts new file mode 100644 index 00000000..e0691a06 --- /dev/null +++ b/scripts/update-algo-ts-peer-dep.ts @@ -0,0 +1,30 @@ +/* eslint-disable no-console */ +import fs from 'fs' + +const AlgoTsPackageName = '@algorandfoundation/algo-ts' +const newVersion = process.argv[2] + +const SemVersionReg = /^\d+\.\d+\.\d+(-((beta)|(alpha))(\.\d+)?)?$/ + +if (!SemVersionReg.test(newVersion)) { + console.error(`Arg 2 of '${newVersion}' should be an npm compatible semantic version number`) + process.exit(1) +} + +if (!fs.existsSync('package.json')) { + console.error('No package.json file could be found in the current working directory') + process.exit(2) +} + +console.info('Loading package.json file') +const pkgJsonText = fs.readFileSync('package.json', 'utf-8') +const pkgJsonObj = JSON.parse(pkgJsonText) + +if (!pkgJsonObj['peerDependencies']) { + pkgJsonObj['peerDependencies'] = {} +} +console.info(`Setting peer dependency on ${AlgoTsPackageName} to ${newVersion}`) +pkgJsonObj['peerDependencies'][AlgoTsPackageName] = newVersion + +fs.writeFileSync('package.json', JSON.stringify(pkgJsonObj, undefined, 2)) +console.info('Writing updated package.json') diff --git a/src/bin/run-cli.ts b/src/bin/run-cli.ts new file mode 100644 index 00000000..473f8666 --- /dev/null +++ b/src/bin/run-cli.ts @@ -0,0 +1,3 @@ +#!/usr/bin/env node + +import '../cli' diff --git a/src/cli.ts b/src/cli.ts index bea11fae..d39ec004 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -35,6 +35,8 @@ const cliArgumentsSchema = z.array(z.string()) function cli() { const commander = new Command().name('puya-ts').description('Algo-TS to Algorand smart contract compiler') + commander.helpCommand(true) + commander .command('build') .argument('', 'The path, or paths to search for compatible .algo.ts files') @@ -122,7 +124,10 @@ function cli() { } }) - commander.parse(process.argv) + if (process.argv.length < 3) { + commander.help() + } else { + commander.parse(process.argv) + } } - cli() diff --git a/tsconfig.json b/tsconfig.json index 32b3b849..07d17774 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ }, "include": [ "src/**/*.ts", + ".tstoolkitrc.ts", "scripts/**/*.ts", "examples/**/*.ts", "rollup.config.ts",