Skip to content

Commit

Permalink
refactor: split build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
verytactical committed Jan 14, 2025
1 parent d4209dd commit b26fb8b
Show file tree
Hide file tree
Showing 40 changed files with 1,032 additions and 933 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ src/grammar/next/grammar.ts
jest.setup.js
jest.teardown.js
/docs
version.build.ts
23 changes: 12 additions & 11 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
"Brujin",
"cleanall",
"codegen",
"comptime",
"Compilables",
"compilables",
"Compilables",
"comptime",
"Daniil",
"decompilation",
"decompile",
Expand All @@ -44,10 +44,10 @@
"elseifnot",
"forall",
"formedness",
"frontmatter",
"funcfiftlib",
"funcid",
"funs",
"frontmatter",
"Georgiy",
"getsimpleforwardfee",
"gettest",
Expand All @@ -56,6 +56,7 @@
"infixl",
"infixr",
"initof",
"Ints",
"ipfs",
"ipld",
"Jesús",
Expand Down Expand Up @@ -109,28 +110,28 @@
"stdlib",
"stmts",
"Ston",
"storer",
"struct",
"structs",
"styleguide",
"subtyping",
"supertypes",
"Tarjan",
"testdata",
"Topup",
"Toncoin",
"Toncoins",
"tonstudio",
"Topup",
"Trunov",
"typechecker",
"uintptr",
"unboc",
"uninit",
"unixfs",
"untypable",
"varuint",
"varint",
"storer",
"Ints",
"varuint",
"viiii",
"workchain",
"xffff",
"привет"
Expand All @@ -149,18 +150,19 @@
"*.spec.ts.snap",
"node_modules",
"dist",
"func",
"grammar/sample.json",
"src/generator/writers/writeStdlib.ts",
"src/func/funcfiftlib.*",
"src/grammar/grammar.ohm-bundle.d.ts",
"src/grammar/test/items-native-fun-funcid.tact",
"src/grammar/test/items-asm-funs.tact",
"src/grammar/test-asm/*.tact",
"src/grammar/test-failed/funcid-*.tact",
"src/grammar/next/grammar.gg",
"src/grammar/next/grammar.ts",
"src/imports/stdlib.ts",
"/src/test/compilation-failed/const-eval-failed.spec.ts",
"src/stdlib/stdlib.ts",
"src/stdlib/stdlib/stdlib.fc",
"src/test/compilation-failed/const-eval-failed.spec.ts",
"src/test/e2e-emulated/address.spec.ts",
"src/test/e2e-emulated/intrinsics.spec.ts",
"src/test/e2e-emulated/optionals.spec.ts",
Expand All @@ -171,7 +173,6 @@
"src/test/compilation-fail/fail-const-eval.spec.ts",
"src/test/e2e-emulated/getter-names-conflict.spec.ts",
"src/test/exit-codes/contracts/compute-phase-errors.tact",
"stdlib/stdlib.fc",
"/docs"
]
}
22 changes: 13 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@
"author": "Steve Korshakov <[email protected]>",
"license": "MIT",
"scripts": {
"gen:grammar:old": "ohm generateBundles --withTypes src/grammar/prev/*.ohm",
"gen:grammar:new": "pgen src/grammar/next/grammar.gg -o src/grammar/next/grammar.ts",
"gen:grammar": "yarn gen:grammar:old && yarn gen:grammar:new",
"gen:pack": "ts-node ./scripts/pack.ts",
"gen:stdlib": "ts-node src/stdlib/stdlib.build.ts",
"gen:func-js": "ts-node src/func/func.build.ts",
"gen:contracts:examples": "ts-node examples/contracts.build.ts",
"gen:contracts:test": "ts-node src/test/contracts.build.ts",
"gen": "yarn gen:grammar && yarn gen:pack && yarn gen:contracts:examples && yarn gen:contracts:test",
"gen": "yarn gen:stdlib && yarn gen:func-js && yarn gen:contracts:examples && yarn gen:contracts:test",
"clean": "rm -fr dist",
"cleanall": "rm -fr dist node_modules",
"build": "tsc && node --no-warnings=ExperimentalWarning -r ts-node/register ./scripts/copy-files",
"test": "yarn gen:grammar && jest",
"copy:stdlib": "ts-node src/stdlib/copy.build.ts",
"copy:grammar": "ts-node src/grammar/prev/copy.build.ts",
"copy:func": "ts-node src/func/copy.build.ts",
"build:grammar:old": "ohm generateBundles --withTypes src/grammar/prev/*.ohm",
"build:grammar:new": "pgen src/grammar/next/grammar.gg -o src/grammar/next/grammar.ts",
"build:grammar": "yarn build:grammar:old && yarn build:grammar:new",
"build": "yarn build:grammar && tsc && yarn copy:stdlib && yarn copy:grammar && yarn copy:func",
"test": "jest",
"coverage": "cross-env COVERAGE=true jest",
"release": "yarn clean && yarn build && yarn coverage && yarn release-it --npm.yarn1",
"type": "tsc --noEmit",
Expand All @@ -35,11 +39,11 @@
"all": "yarn clean && yarn gen && yarn build && yarn coverage && yarn lint:all",
"postinstall": "node .husky/install.mjs || true",
"prepack": "pinst --disable",
"postpack": "pinst --enable"
"postpack": "pinst --enable",
"next-version": "ts-node version.build.ts"
},
"files": [
"dist/**/*",
"src/**/*",
"bin/**/*",
"stdlib/**/*",
"!**/test",
Expand Down
47 changes: 0 additions & 47 deletions scripts/pack.ts

This file was deleted.

3 changes: 0 additions & 3 deletions scripts/tsconfig.json

This file was deleted.

21 changes: 21 additions & 0 deletions src/func/copy.build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as fs from "node:fs/promises";
import * as path from "node:path";
import * as glob from "glob";

const cp = async (fromGlob: string, toPath: string) => {
const files = glob.sync(fromGlob);
for (const file of files) {
await fs.copyFile(file, path.join(toPath, path.basename(file)));
}
};

const main = async () => {
try {
await cp("./src/func/funcfiftlib.*", "./dist/func/");
} catch (e) {
console.error(e);
process.exit(1);
}
};

void main();
9 changes: 9 additions & 0 deletions src/func/func.build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import fs from "fs";
import path from "path";

const sourcePath = path.resolve(__dirname, "funcfiftlib.wasm");
const targetPath = path.resolve(__dirname, "funcfiftlib.wasm.js");

const wasmBase64 = fs.readFileSync(sourcePath).toString("base64");
const wasmBase64js = `module.exports = { FuncFiftLibWasm: '${wasmBase64}' };`;
fs.writeFileSync(targetPath, wasmBase64js);
2 changes: 1 addition & 1 deletion src/func/funcCompile.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs";
import path from "path";
import { Logger } from "../context/logger";
import { funcCompile } from "./funcCompile";
import files from "../imports/stdlib";
import files from "../stdlib/stdlib";

describe("funcCompile", () => {
it("should compile small contract", async () => {
Expand Down
1 change: 0 additions & 1 deletion scripts/copy-files.ts → src/grammar/prev/copy.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const cp = async (fromGlob: string, toPath: string) => {
const main = async () => {
try {
await cp("./src/grammar/prev/grammar.ohm*", "./dist/grammar/prev/");
await cp("./src/func/funcfiftlib.*", "./dist/func/");
} catch (e) {
console.error(e);
process.exit(1);
Expand Down
Loading

0 comments on commit b26fb8b

Please sign in to comment.