Skip to content

Commit

Permalink
Merge pull request #102 from Agoric/ta/compile-ts
Browse files Browse the repository at this point in the history
build ESM dist for npm package
  • Loading branch information
turadg committed Feb 12, 2024
2 parents 53cf87b + da6f0aa commit 4d5d6fb
Show file tree
Hide file tree
Showing 28 changed files with 902 additions and 381 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,18 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Setup synthetic-chain
- name: Build @agoric/synthetic-chain
run: |
# The .ts scripts depend upon this
which tsx || npm install --global tsx
# Enable corepack for packageManager config
corepack enable || sudo corepack enable
yarn install
yarn build
working-directory: packages/synthetic-chain

- name: Prepare Docker config
run: |
# prepare files for bake-action
tsx packages/synthetic-chain prepare-build
yarn synthetic-chain prepare-build
# Verify that all "use" images build across platforms.
- name: Build proposal "use" images
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"packages/*"
],
"scripts": {
"build": "tsx packages/synthetic-chain build",
"test": "tsx packages/synthetic-chain test",
"build": "yarn synthetic-chain build",
"test": "yarn synthetic-chain test",
"format": "prettier --write ."
},
"dependencies": {
Expand Down
30 changes: 15 additions & 15 deletions packages/synthetic-chain/package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
{
"name": "@agoric/synthetic-chain",
"version": "0.0.5-4",
"version": "0.0.6",
"description": "Utilities to build a chain and test proposals atop it",
"bin": "./cli.ts",
"main": "cli.ts",
"bin": "dist/cli/cli.js",
"main": "./dist/lib/index.js",
"type": "module",
"module": "./dist/lib/index.js",
"exports": "./dist/lib/index.js",
"types": "./dist/lib/index.d.ts",
"files": [
"index.js",
"cli.ts",
"docker-bake.hcl",
"src",
"upgrade-test-scripts"
"dist"
],
"scripts": {
"build": "echo No build step",
"test": "NODE_OPTIONS='--loader=tsx --no-warnings' ava",
"test:xs": "exit 0"
"prepare": "yarn build",
"build": "tsup",
"test": "NODE_OPTIONS='--loader=tsx --no-warnings' ava"
},
"dependencies": {
"@endo/zip": "^1.0.1",
"better-sqlite3": "^9.4.0",
"chalk": "^5.3.0",
"execa": "^8.0.1",
"tsx": "^3.14.0",
"typescript": "^5.3.3"
"execa": "^8.0.1"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.9",
"@types/node": "^18.19.14",
"ava": "^5.3.1"
"ava": "^5.3.1",
"tsup": "^8.0.2",
"tsx": "^3.14.0",
"typescript": "^5.3.3"
},
"ava": {
"extensions": {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env tsx

import { evalBundles } from '@agoric/synthetic-chain';

await evalBundles('submission');
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ import {
bakeTarget,
buildProposalSubmissions,
readBuildConfig,
} from './src/cli/build.js';
import {
writeBakefileProposals,
writeDockerfile,
} from './src/cli/dockerfileGen.js';
import { runDoctor } from './src/cli/doctor.js';
import { imageNameForProposal, readProposals } from './src/cli/proposals.js';
import { debugTestImage, runTestImage } from './src/cli/run.js';
} from './build.js';
import { writeBakefileProposals, writeDockerfile } from './dockerfileGen.js';
import { runDoctor } from './doctor.js';
import { imageNameForProposal, readProposals } from './proposals.js';
import { debugTestImage, runTestImage } from './run.js';

const { positionals, values } = parseArgs({
options: {
Expand Down Expand Up @@ -64,12 +61,13 @@ Instead use a builder that supports multiplatform such as depot.dev.
*/
const prepareDockerBuild = () => {
const cliPath = new URL(import.meta.url).pathname;
const publicDir = path.resolve(cliPath, '..', '..');
// copy and generate files of the build context that aren't in the build contents
execSync(`cp -r ${path.resolve(cliPath, '..', 'docker-bake.hcl')} .`);
execSync(`cp -r ${path.resolve(publicDir, 'docker-bake.hcl')} .`);
writeDockerfile(allProposals, buildConfig.fromTag);
writeBakefileProposals(allProposals, buildConfig.platforms);
// copy and generate files to include in the build
execSync(`cp -r ${path.resolve(cliPath, '..', 'upgrade-test-scripts')} .`);
execSync(`cp -r ${path.resolve(publicDir, 'upgrade-test-scripts')} .`);
buildProposalSubmissions(proposals);
// set timestamp of build content to zero to avoid invalidating the build cache
// (change in contents will still invalidate)
Expand Down
2 changes: 1 addition & 1 deletion packages/synthetic-chain/src/cli/dockerfileGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
imageNameForProposal,
isPassed,
} from './proposals.js';
import { Platform } from './build.ts';
import { Platform } from './build.js';

/**
* Templates for Dockerfile stages
Expand Down
2 changes: 1 addition & 1 deletion packages/synthetic-chain/src/cli/doctor.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs from 'node:fs';
import path from 'node:path';
import { ProposalInfo } from './proposals.ts';
import { ProposalInfo } from './proposals.js';
import assert from 'node:assert';
import { execSync } from 'node:child_process';

Expand Down
3 changes: 1 addition & 2 deletions packages/synthetic-chain/src/lib/core-eval-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import { Far, makeMarshal, makeTranslationTable } from './unmarshal.js';
import { agoric } from './cliHelper.js';
import { getISTBalance, mintIST } from './econHelpers.js';
import { ExecutionContext } from 'ava';
import { dbTool } from './vat-status.js';
import { StaticConfig } from './core-eval.ts';
import { StaticConfig } from './core-eval.js';

// move to unmarshal.js?
const makeBoardUnmarshal = () => {
Expand Down
10 changes: 10 additions & 0 deletions packages/synthetic-chain/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export * from './agd-lib.js';
export * from './cliHelper.js';
export * from './commonUpgradeHelpers.js';
export * from './constants.js';
export * from './core-eval-support.js';
export * from './core-eval.js';
export * from './econHelpers.js';
export * from './logging.js';
export * from './vat-status.js';
export * from './webAsset.js';
6 changes: 0 additions & 6 deletions packages/synthetic-chain/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"allowSyntheticDefaultImports": true,
"allowJs": true,
"checkJs": false, // opt in
Expand All @@ -12,14 +11,9 @@
"target": "ESNext"
},
"include": [
"*.js",
"*.ts",
"proposals/**/*.js",
"proposals/**/*.ts",
"src/**/*.js",
"src/**/*.ts",
"test/**/*.js",
"test/**/*.ts",
"tools/**/*.js",
]
}
10 changes: 10 additions & 0 deletions packages/synthetic-chain/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'tsup';

export default defineConfig({
entry: ['src/cli/cli.ts', 'src/lib/index.ts'],
format: ['esm'],
dts: true, // Generate declaration file (.d.ts)
sourcemap: true,
clean: true,
publicDir: true,
});

This file was deleted.

2 changes: 1 addition & 1 deletion proposals/b:zoe1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "^0.0.4-2",
"@agoric/synthetic-chain": "^0.0.6-4",
"ava": "^5.3.1"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion proposals/b:zoe1/post.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import { getIncarnation } from '@agoric/synthetic-chain/src/lib/vat-status.js';
import { getIncarnation } from '@agoric/synthetic-chain';

test(`Zoe vat was upgraded`, async t => {
const incarantion = await getIncarnation('zoe');
Expand Down
4 changes: 1 addition & 3 deletions proposals/b:zoe1/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

set -e

source /usr/src/upgrade-test-scripts/env_setup.sh

yarn ava post.test.js
yarn ava
Loading

0 comments on commit 4d5d6fb

Please sign in to comment.