Skip to content

Commit 1402861

Browse files
authored
chore: patching tests runner (#673)
* Reverting jest `projects` usage, temporarily ignoring selected tests * Temporarily skipping failing test * Adding empty changeset * Adding empty changeset * Reverting `tsconfig` module config back to `CommonJS` * Temporarily commenting file * Testing empty placeholder * Actually skipping test * Removing hbs-related configs, libs, loaders, extensions, etc. * Adding a new prebuild step for transpiling handlebars’ templates * Temporarily using `abi-typegen` bin instead * Adjusting tsconfigs * Updating paths, using [new] sugar-syntax ts-transpiled `hbs` templates * Tyop * Updating lock file * Stop ignoring `abi-typegen` and friends in jest configs * Rolling back `tsconfig` module config * Uncommenting file, adjusting mock and fixing test * Switching from `import` to `require` for dynamic mocked imports in tests * Lintfix * Adjusting ignoring rules for generated files * Debugging CI * Temporarily disabling problematic tests * Debugging CI * Removing packages internal jest configs * Debugging CI * Debugging CI * Removing comments * Debugging CI * Adding TODOs * DRYing `devDependencies`, reusing libs from repo root * Rolling back at using the umbrella package internally * Lintfix * Rolling back last experiment, using internal package directly * Re-enabling `fuels` CLI * Switching back one more time * Re-generating changeset * Adding TODO
1 parent 8c106af commit 1402861

39 files changed

+438
-1448
lines changed

.changeset/wild-turtles-agree.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@fuel-ts/abi-typegen": patch
3+
"fuels": patch
4+
"@fuel-ts/versions": patch
5+
---
6+
7+
Updating conflicting configs, fixing tests runner

.eslintignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.hbs
21
node_modules/
32
coverage/
43
dist/
@@ -10,3 +9,7 @@ CHANGELOG.md
109
# Docs files
1110
_includes/js/custom.js
1211
docs/examples/
12+
13+
# handlebars templates and transpiled ts
14+
*.hbs
15+
*.hbs.ts

.prettierignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
*.hbs
2-
31
dist
42
.coverage_*
53
coverage
@@ -11,3 +9,7 @@ __generated__
119
out
1210
CHANGELOG.md
1311
.chglog/CHANGELOG.tpl.md
12+
13+
# handlebars templates and transpiled ts
14+
*.hbs
15+
*.hbs.ts

.vscode/extensions.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"recommendations": [
33
"orta.vscode-jest",
44
"esbenp.prettier-vscode",
5-
"dbaeumer.vscode-eslint",
6-
"ionutvmi.path-autocomplete"
5+
"dbaeumer.vscode-eslint"
76
]
87
}

.vscode/settings.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,5 @@
2222
"[handlebars]": {
2323
"editor.formatOnSave": false,
2424
"editor.formatOnPaste": false
25-
},
26-
"path-autocomplete.includeExtension": true,
27-
"path-autocomplete.extensionOnImport": true,
28-
"path-autocomplete.excludedItems": {
29-
// do not mess with defaut auto-complete for `js` and `ts`
30-
"**/*.ts": { "when": "**" },
31-
"**/*.js": { "when": "**" }
3225
}
3326
}

jest.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const config: Config.InitialOptions = {
88
modulePathIgnorePatterns: ['/dist/'],
99
coveragePathIgnorePatterns: ['/dist/', '/test/', '.test.ts'],
1010
testTimeout: 15000,
11-
projects: ['<rootDir>/packages/**/jest.config.ts'],
1211
};
1312

1413
export default config;

packages/abi-typegen/.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# ignore transpiled hbs->ts templates and fixturs
2+
src/templates/hbs/transpiled
3+
test/fixtures/templates/transpiled
4+
5+
# ignore contract out dir
6+
test/fixtures/out

packages/abi-typegen/jest.config.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/abi-typegen/package.json

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,16 @@
4242
},
4343
"devDependencies": {
4444
"@fuel-ts/versions": "workspace:*",
45-
"@jest/types": "28.1.0",
4645
"@types/glob": "^8.0.0",
4746
"@types/lodash.upperfirst": "^4.3.7",
4847
"@types/mkdirp": "^1.0.2",
49-
"@types/node": "^18.11.9",
5048
"@types/rimraf": "^3.0.2",
51-
"forc-bin": "workspace:*",
52-
"jest-text-transformer": "^1.0.4",
53-
"ts-node": "^10.9.1",
54-
"tsup": "^5.12.9",
55-
"typescript": "^4.8.4"
49+
"forc-bin": "workspace:*"
5650
},
5751
"scripts": {
52+
"transpile:hbs": "ts-node ./scripts/transpile.hbs.ts",
53+
"prebuild": "pnpm transpile:hbs",
5854
"build": "tsup --dts",
59-
"build:watch": "tsup --dts --watch",
6055
"build:fixtures": "ts-node ./test/fixtures/buildAll.ts",
6156
"test": "jest test --coverage",
6257
"test:watch": "jest test --watch --coverage"
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { readFileSync, rmSync, writeFileSync } from 'fs';
2+
import mkdirp from 'mkdirp';
3+
import { join } from 'path';
4+
// eslint-disable-next-line import/no-extraneous-dependencies
5+
import * as shell from 'shelljs';
6+
7+
const root = join(__dirname, '..');
8+
const templatesDir = join(root, 'src', 'templates', 'hbs');
9+
const fixturesDir = join(root, 'test', 'fixtures', 'templates');
10+
11+
const { log } = console;
12+
13+
export function wrapFile(dirpath: string, filename: string) {
14+
const from = join(dirpath, filename);
15+
const fromContents = readFileSync(from, 'utf-8');
16+
17+
const toDir = join(dirpath, 'transpiled');
18+
const to = join(toDir, `${filename}.ts`);
19+
const toContents = `export default \`${fromContents}\`;`;
20+
21+
rmSync(to, { force: true });
22+
mkdirp.sync(toDir);
23+
writeFileSync(to, toContents);
24+
25+
log(' -', to.replace(root, ''));
26+
}
27+
28+
export function main() {
29+
const templates = shell.ls(templatesDir);
30+
const fixtures = shell.ls(fixturesDir);
31+
32+
const hbsOnly = (t: string) => /\.hbs$/m.test(t);
33+
34+
log(`Transpiling handlebar's templates & fixtures:`);
35+
36+
templates.filter(hbsOnly).forEach((t) => {
37+
wrapFile(templatesDir, t);
38+
});
39+
40+
fixtures.filter(hbsOnly).forEach((f) => {
41+
wrapFile(fixturesDir, f);
42+
});
43+
44+
log('Done.⚡');
45+
}
46+
47+
main();

0 commit comments

Comments
 (0)