-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature run scripts #148
Feature run scripts #148
Conversation
Same as |
@@ -52,6 +52,7 @@ export class TestContract extends Command { | |||
|
|||
const projectDir = path.resolve(); | |||
const testDir = path.resolve("test"); | |||
const typedContractsDir = path.resolve("typedCotracts") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo?
import { fork } from "child_process"; | ||
import path = require("node:path"); | ||
|
||
export class RunCommand extends BaseCommand<typeof RunCommand> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
having both script
and run
looks redundant.
Why not use just run
, so it's more in line with convention in f.ex. npm (swanky run deploy
)?
await new Promise((resolve, reject) => { | ||
const childProcess = fork(scriptPath, [], { | ||
stdio: "inherit", | ||
execArgv: ["--require", "ts-node/register/transpile-only"], | ||
env: { ...process.env }, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered dynamically loading and executing the script instead of running it in a separate process?
That way we could provide for example a runner class, and have it more standardised.
This has an example of it:
https://betterprogramming.pub/how-to-run-typescript-in-javascript-1545e8a36518
packages/core/src/lib/tasks.ts
Outdated
@@ -43,6 +43,15 @@ export async function copyTemplateFiles( | |||
path.resolve(templatesPath, "github"), | |||
path.resolve(projectPath, ".github") | |||
); | |||
await ensureDir(path.resolve(projectPath, "typedContracts")); | |||
await copy( | |||
path.resolve(templatesPath, "typedContracts", "flipper"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the template is not flipper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we are providing a framework, then all of this boilerplate should be abstracted in a runner class, and only f.ex. setConfig()
, run()
methods exposed to the user.
Resolve #144 & #134
What were changed
swanky script run [SCRIPT_NAME]
added.typedContracts
folder moved fromtests/typedContracts
totypedContract
at project root, so that bothtests
andscripts
can use them.typedContracts
are scaffolded when a project is initialized, so that a sample script00_deploy.ts
can use for showcasing how to deploy contracts by using typedContracts (usually they're generated byswanky contract compile
where typechain-polkadot get executed).1.0.0-beta
doesn't need artifacts such as.contract
& metadata.json
externally. They're embedded incontract-info
folder generated by typechain-polkadot command. So, no need for having raw artifacts both intests
andscripts
.