diff --git a/.changeset/three-deers-flash.md b/.changeset/three-deers-flash.md new file mode 100644 index 0000000..b17e491 --- /dev/null +++ b/.changeset/three-deers-flash.md @@ -0,0 +1,8 @@ +--- +"dappstore": patch +"@evmos/dappstore-sdk": patch +"@evmos/dev-wrapper": patch +"@evmos/utils": patch +--- + +Refactor build pipeline diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..854b106 --- /dev/null +++ b/LICENSE @@ -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). diff --git a/bun.lockb b/bun.lockb index 76b6cc2..47062ad 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 933b015..6b071dc 100644 --- a/package.json +++ b/package.json @@ -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}\"", @@ -30,6 +30,6 @@ ], "dependencies": { "@changesets/cli": "^2.27.1", - "cross-spawn": "^7.0.3" + "@evmos/utils": "workspace:*" } } diff --git a/packages/dappstore-cli/build.ts b/packages/dappstore-cli/build.ts index 1fb7b75..5f2306d 100644 --- a/packages/dappstore-cli/build.ts +++ b/packages/dappstore-cli/build.ts @@ -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"), +}); diff --git a/packages/dappstore-cli/package.json b/packages/dappstore-cli/package.json index 4baacb4..edfb4e2 100644 --- a/packages/dappstore-cli/package.json +++ b/packages/dappstore-cli/package.json @@ -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", diff --git a/packages/dappstore-cli/src/index.ts b/packages/dappstore-cli/src/index.ts index 0571ed1..8de7cdd 100644 --- a/packages/dappstore-cli/src/index.ts +++ b/packages/dappstore-cli/src/index.ts @@ -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); diff --git a/packages/dappstore-cli/src/init/write-template.ts b/packages/dappstore-cli/src/init/write-template.ts index 8ebbcf2..0785f2e 100644 --- a/packages/dappstore-cli/src/init/write-template.ts +++ b/packages/dappstore-cli/src/init/write-template.ts @@ -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(); diff --git a/packages/dappstore-cli/tsconfig.json b/packages/dappstore-cli/tsconfig.json index 7415bd5..32c3fe1 100644 --- a/packages/dappstore-cli/tsconfig.json +++ b/packages/dappstore-cli/tsconfig.json @@ -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"] diff --git a/packages/dappstore-sdk/build.ts b/packages/dappstore-sdk/build.ts index e1a9aac..e98d19b 100644 --- a/packages/dappstore-sdk/build.ts +++ b/packages/dappstore-sdk/build.ts @@ -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"), +}); diff --git a/packages/dev-wrapper/vite.config.ts b/packages/dev-wrapper/vite.config.ts index 495433f..9cc50ea 100644 --- a/packages/dev-wrapper/vite.config.ts +++ b/packages/dev-wrapper/vite.config.ts @@ -4,9 +4,4 @@ import react from "@vitejs/plugin-react"; // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], - // build: { - // watch: { - // exclude: "node_modules/**", - // }, - // }, }); diff --git a/packages/utils/CHANGELOG.md b/packages/utils/CHANGELOG.md new file mode 100644 index 0000000..99515b8 --- /dev/null +++ b/packages/utils/CHANGELOG.md @@ -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 diff --git a/packages/utils/package.json b/packages/utils/package.json new file mode 100644 index 0000000..feaa0f0 --- /dev/null +++ b/packages/utils/package.json @@ -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" + } +} diff --git a/packages/utils/src/build.ts b/packages/utils/src/build.ts new file mode 100644 index 0000000..198ed90 --- /dev/null +++ b/packages/utils/src/build.ts @@ -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; + peerDependencies?: Record; + devDependencies?: Record; + }; + + 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(); + } +}; diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/packages/utils/src/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json new file mode 100644 index 0000000..f1a7682 --- /dev/null +++ b/packages/utils/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "@evmos/config/base.json", + "compilerOptions": {}, + "include": ["./src/**/*"], + "exclude": ["node_modules", "dist"] +}