Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix packages deps & files; rebuild crypto; use Jake #105

Merged
merged 6 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"access": "restricted",
"baseBranch": "iroha2",
"updateInternalDependencies": "patch",
"ignore": []
"ignore": ["@iroha2/crypto-test-*", "@iroha2/client-test-*"]
}
8 changes: 8 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,13 @@ module.exports = {
'vue/html-indent': ['warn', 2],
},
},
// Jakefiles
{
files: ['packages/crypto/etc/jakefile.ts', 'etc/jakefile.ts'],
globals: {
desc: true,
task: true,
},
},
],
}
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Iroha JavaScript

JavaScript SDK for [Iroha 2](https://github.com/hyperledger/iroha/tree/iroha2/).

## Explore Jake tasks

```bash
pnpm jake -t
```
112 changes: 112 additions & 0 deletions etc/jakefile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/**
* TODO move client package test scripts here, so it will be possible
* to avoid duplicated builds during CI.
*/

import 'jake'
import del from 'del'
import { $ } from 'zx'
import {
BUNDLE_PACKAGES,
BundlePackage,
PUBLIC_PACKAGES,
PUBLIC_PACKAGES_WITH_API_REPORT,
getBundlePackageExternals,
getBundlePackageInput,
getBundlePackageOutput,
getPackageApiExtractorConfigFile,
scopePackage,
} from './meta'
import { Extractor, ExtractorConfig, ExtractorResult } from '@microsoft/api-extractor'
import * as esbuild from 'esbuild'

async function runApiExtractor(localBuild = false) {
for (const pkg of PUBLIC_PACKAGES_WITH_API_REPORT) {
const extractorConfig: ExtractorConfig = ExtractorConfig.loadFileAndPrepare(getPackageApiExtractorConfigFile(pkg))

// Invoke API Extractor
const extractorResult: ExtractorResult = Extractor.invoke(extractorConfig, {
localBuild,
showVerboseMessages: true,
})

if (!extractorResult.succeeded) {
throw new Error(
`API Extractor for package ${pkg} completed with ${extractorResult.errorCount} errors` +
` and ${extractorResult.warningCount} warnings`,
)
}
}
}

async function bundleSinglePackage(name: BundlePackage, format: 'esm' | 'cjs') {
await esbuild.build({
entryPoints: [getBundlePackageInput(name)],
bundle: true,
outfile: getBundlePackageOutput(name, format),
external: getBundlePackageExternals(name).toArray(),
target: 'esnext',
platform: 'neutral',
format,
sourcemap: true,
logLevel: 'info',
define: {
'import.meta.vitest': 'undefined',
},
})
}

desc('Clean all build artifacts')
task('clean', async () => {
await del([
'**/dist',
// their dists are static
'!./packages/crypto/packages/*/dist',
'**/dist-tsc',
])
})

task('build-tsc', ['clean'], async () => {
await $`pnpm build:tsc`
})

task('build-isomoprhic-ws-n-fetch', async () => {
await $`pnpm build:isomorphic-ws-and-fetch`
})

task('build-bundle', async () => {
function* bundles(): Generator<Promise<void>> {
for (const name of BUNDLE_PACKAGES) {
for (const format of ['esm', 'cjs'] as const) {
yield bundleSinglePackage(name, format)
}
}
}

await Promise.all(bundles())
})

desc('Extract APIs and verify (also rollup .d.ts)')
task('api-extract', ['build-tsc'], async () => {
await runApiExtractor()
})

desc('Extract APIs and update them')
task('api-extract-local', ['build-tsc'], async () => {
await runApiExtractor(true)
})

desc('Build everything')
task('build', ['clean', 'build-tsc', 'build-isomoprhic-ws-n-fetch', 'api-extract', 'build-bundle'])

desc('Publish all public packages')
task('publish-all', async () => {
const filters = [
...PUBLIC_PACKAGES.toSeq()
.map(scopePackage)
.map((x) => [`--filter`, x])
.toList(),
].flat()

await $`pnpm ${filters} publish --no-git-checks`
})
21 changes: 0 additions & 21 deletions etc/scripts/api-extractor.ts

This file was deleted.

39 changes: 0 additions & 39 deletions etc/scripts/bundle.ts

This file was deleted.

30 changes: 0 additions & 30 deletions gulpfile.ts

This file was deleted.

3 changes: 3 additions & 0 deletions jakefile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* eslint-disable @typescript-eslint/no-require-imports */
require('esbuild-register')
module.exports = require('./etc/jakefile')
27 changes: 12 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,28 @@
"version": "0.0.0",
"private": true,
"scripts": {
"gulpts": "pnpm gulp --require esbuild-register -f gulpfile.ts",
"preinstall": "npx only-allow pnpm",
"test": "run-s test:unit test:crypto test:client",
"test:unit": "vitest run",
"test:crypto": "pnpm test --filter monorepo-crypto",
"test:client": "pnpm test:integration --filter client",
"clean": "pnpm gulpts clean",
"build": "pnpm gulpts build",
"build:tsc": "pnpm build:tsc --parallel --filter data-model --filter client --filter i64-fixnum",
"build:isomorphic-ws-and-fetch": "pnpm build --filter \"@iroha2/client-isomorphic-*\"",
"build:bundle": "pnpm gulpts bundle",
"publish-all": "pnpm gulpts publishAll",
"test:crypto": "pnpm --filter monorepo-crypto run test",
"test:client": "pnpm --filter client run test:integration",
"clean": "pnpm jake clean",
"build": "pnpm jake build",
"build:tsc": "pnpm --parallel --filter !monorepo --filter data-model --filter client --filter i64-fixnum run build:tsc",
"build:isomorphic-ws-and-fetch": "pnpm --filter \"@iroha2/client-isomorphic-*\" run build",
"build:bundle": "pnpm jake build-bundle",
"publish-all": "pnpm jake publish-all",
"type-check": "tsc --noEmit",
"api:extract": "pnpm gulpts runApiExtractor",
"api:extract:local": "pnpm gulpts runApiExtractorLocal",
"api:extract": "pnpm jake api-extract",
"api:extract:local": "pnpm jake api-extract-local",
"format:fix": "prettier-eslint \"**/*.{ts,js,vue,json}\" --write"
},
"devDependencies": {
"@changesets/cli": "^2.22.0",
"@iroha2/dev-iroha-bins": "workspace:^0.0.0",
"@iroha2/test-peer": "workspace:^0.0.1",
"@microsoft/api-extractor": "^7.24.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@types/gulp": "^4.0.9",
"@types/jake": "^0.0.33",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"consola": "^2.15.3",
Expand All @@ -38,13 +36,12 @@
"eslint-config-alloy": "^4.5.1",
"eslint-plugin-cypress": "^2.12.1",
"eslint-plugin-vue": "^8.5.0",
"gulp": "^4.0.2",
"immutable": "^4.0.0",
"jake": "^10.8.5",
"npm-run-all": "^4.1.5",
"prettier": "^2.5.1",
"prettier-eslint": "^13.0.0",
"prettier-eslint-cli": "^5.0.1",
"sass": "^1.49.9",
"type-fest": "^2.12.0",
"typescript": "^4.6.4",
"vitest": "^0.12.6",
Expand Down
7 changes: 7 additions & 0 deletions packages/client-isomorphic-fetch/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @iroha2/client-isomorphic-fetch

## 0.2.0

### Minor Changes

- 49c8451: **BREAKING**: `node-fetch` v2 → v3
4 changes: 2 additions & 2 deletions packages/client-isomorphic-fetch/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iroha2/client-isomorphic-fetch",
"version": "0.1.0",
"version": "0.2.0",
"license": "Apache 2.0",
"main": "src/node.ts",
"module": "src/native.ts",
Expand All @@ -19,7 +19,7 @@
"build:native": "esbuild --bundle src/native.ts --outfile=dist/native.js --format=esm"
},
"dependencies": {
"node-fetch": "^2.6.6"
"node-fetch": "^3.2.4"
},
"devDependencies": {
"esbuild": "^0.14.27",
Expand Down
11 changes: 11 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @iroha2/client

## 1.2.1

### Patch Changes

- 49c8451: chore: include only necessary files into `files` field in the `package.json`
- Updated dependencies [49c8451]
- Updated dependencies [49c8451]
- @iroha2/crypto-core@0.1.1
- @iroha2/data-model@1.2.1
- @iroha2/client-isomorphic-fetch@0.2.0

## 1.2.0

### Minor Changes
Expand Down
24 changes: 13 additions & 11 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "@iroha2/client",
"version": "1.2.0",
"version": "1.2.1",
"main": "src/lib.ts",
"publishConfig": {
"main": "dist/lib.cjs.js",
"module": "dist/lib.esm.js",
"types": "dist/lib.d.ts",
"files": [
"dist"
]
"types": "dist/lib.d.ts"
},
"files": [
"dist",
"CHANGELOG.md"
],
"license": "Apache 2.0",
"engines": {
"node": ">=14.0.0"
Expand All @@ -18,22 +19,23 @@
"test": "vitest run",
"test:integration": "run-s test:prepare test:node test:web",
"test:prepare": "run-p test:prepare:build-isomorphic test:prepare:peer",
"test:prepare:build-isomorphic": "pnpm run build --parallel --filter \"@iroha2/client-isomorphic-*\"",
"test:prepare:build-isomorphic": "pnpm --parallel --filter \"@iroha2/client-isomorphic-*\" run build",
"test:prepare:peer": "esno test/integration/prepare-peer",
"test:node": "pnpm test --filter client-test-node",
"test:web": "pnpm test --filter client-test-web",
"test:node": "pnpm --filter client-test-node test",
"test:web": "pnpm --filter client-test-web test",
"build:tsc": "tsc"
},
"dependencies": {
"@iroha2/client-isomorphic-fetch": "workspace:^0.1.0",
"@iroha2/client-isomorphic-fetch": "workspace:^0.2.0",
"@iroha2/client-isomorphic-ws": "workspace:^0.2.0",
"@iroha2/crypto-core": "workspace:^0.1.0",
"@iroha2/data-model": "workspace:^1.2.0",
"@iroha2/crypto-core": "workspace:^0.1.1",
"@iroha2/data-model": "workspace:^1.2.1",
"debug": "^4.3.4",
"emittery": "^0.10.1",
"json-bigint": "^1.0.0"
},
"devDependencies": {
"@types/debug": "^4.1.7",
"consola": "^2.15.3",
"esno": "^0.12.1",
"npm-run-all": "^4.1.5",
Expand Down
Loading