Skip to content

Commit

Permalink
Refactor build pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
julia-script committed Feb 19, 2024
1 parent 6c8f4af commit c1ce02c
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 81 deletions.
8 changes: 8 additions & 0 deletions .changeset/three-deers-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"dappstore": patch
"@evmos/dappstore-sdk": patch
"@evmos/dev-wrapper": patch
"@evmos/utils": patch
---

Refactor build pipeline
64 changes: 64 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
Evmos Non-Commercial License

Version 1.0 dated April 21th, 2023

This license contains the terms and conditions under which Tharsis Labs Ltd.
(“Company”) makes available its Software. Your use of the Software is subject to
these terms and conditions.

Company grants you (“Licensee”) a license to use, modify, and redistribute the
Software, but only (a) for Non-Commercial Use, or (b) for Commercial Use only on
the Designated Blockchains.

If Licensee makes available a copy of the Software to any third party, the
Software must be subject to the terms of this license only, and Licensee must
provide a copy of this license to that third party. All restrictions and
conditions of this license apply to the Software or any portion or modification
of the Software made under this license.

These terms do not allow Licensee to sublicense or transfer any of Licensee’s
rights to anyone else. These terms do not imply any other licenses not expressly
granted in this license.

If Licensee violates any of these terms or uses the Software in a way not
authorized under this license, the license granted to Licensee ends immediately.
If Licensee makes, or authorizes any other person to make, any written claim
that the Software, or any other Evmos Product (see below), infringes or
contributes to the infringement of any patent, all rights granted to Licensee
under this license end immediately.

As far as the law allows, the Software is provided AS IS, without any warranty
or condition, and Company will not be liable to Licensee for any damages arising
out of these terms or the use or nature of the Software, under any kind of legal
claim.

Terms in this license are used as follows:

“Software” means the blockchain software developed by the Company, which is the
implementation of the Evmos blockchains available at
“https://github.com/evmos/evmos” and the Evmos applications at
“https://github.com/evmos/backend” and “https://github.com/evmos/apps” as may be
updated from time to time.

"Designated Blockchains" refer to the version of the digital blockchain ledger
that, at any given time, is recognized as canonical in accordance with the
blockchain consensus.

A “Evmos Product” is any product or service offered by the Company or its
affiliates.

“Non-Commercial Use” means academic, scientific, or research and development
use, or evaluating the Software (such as. through auditing), but does not
include the creation of a publicly available blockchain, precompiled smart
contracts, or other distributed-ledger technology systems that facilitate any
transaction of economic value.

“Commercial Use” is any use that is not a Non-Commercial Use.

To “use” means any use, modification, distribution or other exploitation of the
Software or any part of it.

---

For more information, please refer to the official ENCL-1.0 FAQ
(https://github.com/evmos/apps/blob/main/LICENSE_FAQ.md).
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "dappstore-sdk",
"private": true,
"scripts": {
"build": "turbo build --filter=./packages/*",
"build": "turbo build",
"dev": "turbo dev",
"lint": "turbo lint",
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
Expand Down Expand Up @@ -30,6 +30,6 @@
],
"dependencies": {
"@changesets/cli": "^2.27.1",
"cross-spawn": "^7.0.3"
"@evmos/utils": "workspace:*"
}
}
42 changes: 9 additions & 33 deletions packages/dappstore-cli/build.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
// @ts-nocheck
import Bun from "bun";
import { dependencies, peerDependencies } from "./package.json";
import { watch } from "node:fs";
export const build = async () => {
const result = await Bun.build({
entrypoints: ["./src/index.ts"],
target: "node",
format: "esm",
external: [...Object.keys(dependencies), ...Object.keys(peerDependencies)],
outdir: "./dist",
});
import { build } from "@evmos/utils/src/build";

if (result.success === false) {
result.logs.forEach((log) => console.error(log));
return;
}
console.log("Build successful");
};
await build();
build({
entryPoints: ["./src/index.ts"],

if (process.argv.includes("--watch")) {
const srcWatcher = watch(
`${import.meta.dir}/src`,
{ recursive: true },
async (event, filename) => {
console.log(`Detected ${event} in ${filename} (src)`);
await build();
}
);
process.on("SIGINT", () => {
srcWatcher.close();
process.exit(0);
});
}
platform: "node",
format: "esm",
bundle: true,
outdir: "./dist",
watch: process.argv.includes("--watch"),
});
7 changes: 4 additions & 3 deletions packages/dappstore-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,24 @@
"main": "dist/index.js",
"scripts": {
"build": "bun run ./build.ts",
"dev": "bun run build -- --watch"
"dev": "bun run ./build.ts --watch"
},
"bin": {
"dappstore": "./dist/index.js"
},
"peerDependencies": {},
"devDependencies": {
"@types/node": "^20.10.6",
"typescript": "^5.3.3"
},
"dependencies": {
"@commander-js/extra-typings": "^12.0.0",
"@evmos/dev-wrapper": "0.0.3",
"@commander-js/extra-typings": "^12.0.0",
"@types/cross-spawn": "^6.0.6",
"@types/inquirer": "^9.0.7",
"autoprefixer": "^10.4.17",
"chalk": "^5.3.0",
"cross-spawn": "^7.0.3",
"express": "^4.18.2",
"inquirer": "^9.2.14",
"lodash-es": "^4.17.21",
"postcss": "^8.4.33",
Expand Down
4 changes: 3 additions & 1 deletion packages/dappstore-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
import "./dev";
import "./init/init";
import { program } from "@commander-js/extra-typings";
program.version(process.env.npm_package_version ?? "");
program.name("DAppStore CLI");

program.parse(process.argv);
await program.parseAsync(process.argv);
3 changes: 1 addition & 2 deletions packages/dappstore-cli/src/init/write-template.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { writeFile } from "fs/promises";
import { readTemplate } from "./get-template" with { type: "macro" };

import { readTemplate } from "./get-template";
export const writeTemplate = async (destination: string) => {
const templatePath = await readTemplate();

Expand Down
3 changes: 2 additions & 1 deletion packages/dappstore-cli/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "@evmos/config/base.json",
"compilerOptions": {
"outDir": "./dist",
"target": "ESNext"
"target": "ESNext",
"module": "ESNext"
},
"include": ["./src/**/*", "./src/**/*.d.ts"],
"exclude": ["node_modules", "dist"]
Expand Down
43 changes: 9 additions & 34 deletions packages/dappstore-sdk/build.ts
Original file line number Diff line number Diff line change
@@ -1,35 +1,10 @@
// @ts-nocheck
import Bun from "bun";
import { dependencies, peerDependencies } from "./package.json";
import { version } from "./package.json";
import { watch } from "node:fs";
export const build = async () =>
await Bun.build({
entrypoints: ["./src/index.ts", "./src/host.ts"],
target: "browser",
format: "esm",
external: [...Object.keys(dependencies), ...Object.keys(peerDependencies)],
define: {
["process.env.npm_package_version"]: JSON.stringify(version),
},
outdir: "./dist",
});
import { build } from "@evmos/utils/src/build";

await build();
if (process.argv.includes("--watch")) {
const srcWatcher = watch(
`${import.meta.dir}/src`,
{ recursive: true },
async (event, filename) => {
await build();

console.log(`Detected ${event} in ${filename} (src)`);
}
);
process.on("SIGINT", () => {
srcWatcher.close();
process.exit(0);
});
} else {
await build();
}
build({
entryPoints: ["./src/index.ts", "./src/host.ts"],
platform: "browser",
format: "esm",
bundle: true,
outdir: "./dist",
watch: process.argv.includes("--watch"),
});
5 changes: 0 additions & 5 deletions packages/dev-wrapper/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,4 @@ import react from "@vitejs/plugin-react";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
// build: {
// watch: {
// exclude: "node_modules/**",
// },
// },
});
19 changes: 19 additions & 0 deletions packages/utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# @evmos/dappstore-sdk

## 0.0.4

### Patch Changes

- 5295941: Fix package resolution

## 0.0.2

### Patch Changes

- 52bf8c3: Creates init command

## 0.0.1

### Patch Changes

- 18989f2: Release setup
16 changes: 16 additions & 0 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "@evmos/utils",
"type": "module",
"sideEffects": false,
"version": "1.0.0",
"scripts": {},
"devDependencies": {
"@types/lodash-es": "^4.17.12",
"@types/node": "^20.10.6",
"lodash-es": "^4.17.21",
"typescript": "^5.3.3"
},
"dependencies": {
"esbuild": "^0.20.1"
}
}
42 changes: 42 additions & 0 deletions packages/utils/src/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import Bun, { BuildConfig } from "bun";
import path from "path";
import * as esbuild from "esbuild";

export const build = async ({
watch,
...config
}: esbuild.BuildOptions & { watch?: boolean }) => {
const pkg = (await Bun.file(
path.join(process.cwd(), "package.json")
).json()) as {
version?: string;
dependencies?: Record<string, string>;
peerDependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
};

const context = await esbuild.context({
...config,

external: [
...Object.keys(pkg.dependencies ?? {}),
...Object.keys(pkg.peerDependencies ?? {}),
...(config.external ?? []),
],
logLevel: "info",

define: {
["process.env.npm_package_version"]: JSON.stringify(pkg.version),
...(config.define ?? {}),
},
});
if (watch) {
await context.watch({});

console.log("Watching for changes");
} else {
const result = await context.rebuild();

await context.dispose();
}
};
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
6 changes: 6 additions & 0 deletions packages/utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "@evmos/config/base.json",
"compilerOptions": {},
"include": ["./src/**/*"],
"exclude": ["node_modules", "dist"]
}

0 comments on commit c1ce02c

Please sign in to comment.