Skip to content

Commit

Permalink
refactor: split build scripts (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
verytactical authored Jan 16, 2025
1 parent 9cd0675 commit 1756916
Show file tree
Hide file tree
Showing 43 changed files with 1,028 additions and 962 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ src/grammar/next/grammar.ts
jest.setup.js
jest.teardown.js
/docs
version.build.ts
8 changes: 1 addition & 7 deletions .github/workflows/tact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
yarn gen
yarn build
- name: Check there are no errors to be fixed in package.json and no uncommited changes
- name: Check there are no errors to be fixed in package.json and no uncommitted changes
run: |
npm pkg fix && git diff --exit-code
Expand Down Expand Up @@ -98,12 +98,6 @@ jobs:
run: |
yarn knip
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
if: runner.os != 'Windows'
with:
scandir: "./scripts"

- name: Show an example .pkg file on Windows
if: runner.os == 'Windows'
run: |
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
/src/grammar/prev/grammar.ohm-bundle.d.ts
/src/grammar/prev/grammar.ohm-bundle.js
src/grammar/next/grammar.ts
/src/imports/stdlib.ts
/src/stdlib/stdlib.ts
/grammar
/docs
12 changes: 8 additions & 4 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@
"untypable",
"varint",
"varuint",
"viiii",
"varint",
"storer",
"Ints",
"workchain",
"xffff",
"привет"
Expand All @@ -150,18 +154,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 @@ -174,7 +179,6 @@
"src/test/exit-codes/contracts/compute-phase-errors.tact",
"src/test/e2e-emulated/map-tests/build",
"src/test/e2e-emulated/map-tests/map-properties-key-value-types.ts",
"stdlib/stdlib.fc",
"/docs"
]
}
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@
"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:contracts:test:map": "ts-node ./src/test/e2e-emulated/map-tests/generate.ts",
"gen": "yarn gen:grammar && yarn gen:pack && yarn gen:contracts:examples && yarn gen:contracts:test && yarn gen:contracts:test:map",
"gen": "yarn gen:grammar && yarn gen:stdlib && yarn gen:func-js && yarn gen:contracts:examples && yarn gen:contracts:test && yarn gen:contracts:test:map",
"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": "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 @@ -36,11 +40,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.

31 changes: 0 additions & 31 deletions scripts/set-next-version.sh

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 1756916

Please sign in to comment.