-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new infra for code snippets (#2651)
* Starting new code-snippets app * Porting getting-started snippets * Ignoring new app in changesets * Adding changeset * Ignoring wrapped snippets files (generated) * Ignore test files trying to import files that haven’t been built yet * Using real code/file rather than code-string * Adding example using `launchTestNode` and `LOCAL_NETWORK_URL` overrides * Skipping until forc workspace has at least one member * Renaming variable * Fixing regex * Ignoring lint issues individually * Removing from browser group * Lintfix * Restoring console after snippet * Keeping wrapper free from weird hacks * Adding mock utility * Using mocking utility * Validating if `nertworkUrl` was properly mocked * Mock provider instead? * Mocking only for localhost * Adjusting snippets * Wrapping snippet in a try/catch * Adding blank spaces * Removing mocking utility * Adding pass-through options for `console.log` calls * Adding new slot for injecting test node launcher into wrapped snippet * Injecting node launcher for snippets using `LOCAL_NETWORK_URL` * Trim snippets * Cleanup snippets tests * Stop ignoring test for `docs-snippets2` * Re-adding `docs-snippets2` tests to knip ignore list * Using internal builds * Fixing ignore rule * Adding basic counter Sway project * Improving scripts * Adding sample env file * Standardizing snippets and tests * Validate env constants existence * Drafting new snippet * Adjusting script command * Removing unnecessary wallet * Extacting launcher into another file * New API draft * Syncing env and launcher template * Better docs * Adding new sway script * Removing API draft * Fixing file location * Add script to workspace * Improve snippet * Using new snippets * Add new API draft * Matching extra blankspace * Ignoring env file * Adding region marks * Avoid repetition * Trim env consts * Cleanup * Playing around new API * Tidying up * Ignoring experimental file * Ignoring generated files in eslint * Adjusting wallets count * Moving chunk around * Adjusting ignore rule * Improving imports manipulation * Adding comments * Adjusting template markers * Tyop * Update draft * Update title * Adjust deployment usage * Updating example * Removing temp draft * Removing temp draft section * Updating broken test * Using `NETWORK_URL` across the board * Reword comment * Adding scripts dir to tsconfig * Starting with more wallets * Automatically generating tests for code snippets * Forcing assertion failures to throw * WIP * Changing back to `console.log` * Adding testing groups to template * Renaming variable * Removing redundancy in template handling * Upgrading dependency * Updating lock file * Lintfix - keeping eslint disable at the top * Normalizing language across all snippets * Nit * Nit II * Fixing package names * Adjusting ignored package names * Deleting obsolete files --------- Co-authored-by: Sérgio Torres <[email protected]>
- Loading branch information
1 parent
3ad28bf
commit fff7047
Showing
30 changed files
with
602 additions
and
398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
--- | ||
|
||
feat: new infra for code snippets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
apps/docs-snippets/src/guide/introduction/getting-started.test.ts
This file was deleted.
Oops, something went wrong.
106 changes: 0 additions & 106 deletions
106
apps/docs-snippets/src/guide/transactions/transaction-parameters.test.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
extends: ['../../.eslintrc.js'], | ||
rules: { | ||
'no-console': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
src/typegend | ||
src/**/*.test.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { createConfig } from 'fuels'; | ||
|
||
export default createConfig({ | ||
workspace: './sway', | ||
output: './src/typegend', | ||
forcBuildFlags: ['--release'], | ||
forcPath: 'fuels-forc', | ||
fuelCorePath: 'fuels-core', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "docs-snippets2", | ||
"version": "0.67.0", | ||
"description": "", | ||
"private": true, | ||
"scripts": { | ||
"build": "run-s wrap:snippets build:forc", | ||
"build:forc": "pnpm fuels build", | ||
"wrap:snippets": "tsx scripts/wrap-snippets.ts", | ||
"pretest": "pnpm build", | ||
"test": "cd ../.. && pnpm run test:filter apps/docs-snippets2" | ||
}, | ||
"dependencies": { | ||
"fuels": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"glob": "^10.4.5" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { launchTestNode } from 'fuels/test-utils'; | ||
|
||
using node = await launchTestNode({ walletsConfig: { count: 5 } }); | ||
|
||
const LOCAL_NETWORK_URL = node.provider.url; | ||
|
||
const [w1, w2, w3, w4, w5] = node.wallets; | ||
|
||
const WALLET_ADDRESS = w1.address; | ||
const WALLET_PVT_KEY = w1.privateKey; | ||
|
||
const WALLET_ADDRESS_2 = w2.address; | ||
const WALLET_PVT_KEY_2 = w2.privateKey; | ||
|
||
const WALLET_ADDRESS_3 = w3.address; | ||
const WALLET_PVT_KEY_3 = w3.privateKey; | ||
|
||
const WALLET_ADDRESS_4 = w4.address; | ||
const WALLET_PVT_KEY_4 = w4.privateKey; | ||
|
||
const WALLET_ADDRESS_5 = w5.address; | ||
const WALLET_PVT_KEY_5 = w5.privateKey; | ||
|
||
const all = [ | ||
LOCAL_NETWORK_URL, | ||
WALLET_ADDRESS, | ||
WALLET_PVT_KEY, | ||
WALLET_ADDRESS_2, | ||
WALLET_PVT_KEY_2, | ||
WALLET_ADDRESS_3, | ||
WALLET_PVT_KEY_3, | ||
WALLET_ADDRESS_4, | ||
WALLET_PVT_KEY_4, | ||
WALLET_ADDRESS_5, | ||
WALLET_PVT_KEY_5, | ||
]; | ||
|
||
console.assert( | ||
all.every((x) => !!x), | ||
`All constants should be truthy.` | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-disable no-global-assign */ | ||
|
||
// %IMPORTS% | ||
|
||
const consoleBkp = { ...console }; | ||
|
||
afterAll(() => { | ||
console = { ...consoleBkp }; | ||
}); | ||
|
||
/** | ||
* @group node | ||
* @group browser | ||
*/ | ||
test('%NAME%', async () => { | ||
// TEST NODE LAUNCHER ———>>> | ||
// %NODE_LAUNCHER% | ||
// <<<——— TEST NODE LAUNCHER | ||
|
||
console = { | ||
...console, | ||
log(logMsg, isTruthy) { | ||
if (!isTruthy) { | ||
throw new Error(logMsg); | ||
} | ||
}, | ||
}; | ||
|
||
// SNIPPET ———>>> | ||
// %SNIPPET% | ||
// <<<——— SNIPPET | ||
|
||
return Promise.resolve(); | ||
}); |
Oops, something went wrong.