-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
converted bash scripts from live-common
- Loading branch information
1 parent
348a52b
commit 6304914
Showing
29 changed files
with
1,603 additions
and
1,155 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
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
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,33 @@ | ||
#!/usr/bin/env zx | ||
import "zx/globals"; | ||
import rimraf from "rimraf"; | ||
|
||
cd(path.join(__dirname, "..")); | ||
|
||
const remover = async () => { | ||
await rimraf("lib", (e) => { | ||
if (e) echo(chalk.red(e)); | ||
}); | ||
await rimraf("src/data/icons/react*", (e) => { | ||
if (e) echo(chalk.red(e)); | ||
}); | ||
}; | ||
|
||
await remover(); | ||
|
||
await $`zx ./scripts/sync-families-dispatch.mjs`; | ||
|
||
await $`node ./scripts/buildReactIcons.js`; | ||
await $`node ./scripts/buildReactFlags.js`; | ||
|
||
const prefix = $.prefix; | ||
|
||
within(async () => { | ||
$.prefix = prefix; | ||
await $`NODE_ENV=production pnpm tsc --project src/tsconfig.json`; | ||
}); | ||
|
||
within(async () => { | ||
$.prefix = prefix; | ||
await $`NODE_ENV=production pnpm tsc --project src/tsconfig.json -m ES6 --outDir lib-es`; | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
143 changes: 143 additions & 0 deletions
143
libs/ledger-live-common/scripts/sync-families-dispatch.mjs
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,143 @@ | ||
#!/usr/bin/env zx | ||
import "zx/globals"; | ||
import rimraf from "rimraf"; | ||
|
||
const targets = [ | ||
"customAddressValidation.ts", | ||
"hw-getAddress.ts", | ||
"hw-signMessage.ts", | ||
"transaction.ts", | ||
"bridge/js.ts", | ||
"bridge/mock.ts", | ||
"cli-transaction.ts", | ||
"specs.ts", | ||
"speculos-deviceActions.ts", | ||
"deviceTransactionConfig.ts", | ||
"mock.ts", | ||
"account.ts", | ||
"exchange.ts", | ||
"presync.ts", | ||
"platformAdapter.ts", | ||
]; | ||
|
||
cd(path.join(__dirname, "..", "src")); | ||
rimraf.sync("generated"); | ||
await fs.promises.mkdir("generated"); | ||
await fs.promises.mkdir("generated/bridge"); | ||
|
||
const families = ( | ||
await fs.promises.readdir("families", { withFileTypes: true }) | ||
) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name); | ||
|
||
async function genTarget(targets, families) { | ||
targets.forEach(async (target) => { | ||
const imprtTarget = target.replace(".ts", ""); | ||
const outpath = path.join("generated", target); | ||
let imports = ``; | ||
let exprts = `export default {`; | ||
|
||
for (const family of families) { | ||
if (fs.existsSync(path.join("families", family, target))) { | ||
const subPath = target.split("/"); | ||
let rewind = "../"; | ||
if (subPath.length >= 2) { | ||
let subs = subPath.length / 2; | ||
while (subs > 0) { | ||
rewind += "../"; | ||
subs--; | ||
} | ||
} | ||
imports += `import ${family} from "${rewind}families/${family}/${imprtTarget}"; | ||
`; | ||
exprts += ` | ||
${family},`; | ||
} | ||
} | ||
|
||
exprts += ` | ||
}; | ||
`; | ||
|
||
const str = `${imports} | ||
${exprts}`; | ||
|
||
await fs.promises.writeFile(outpath, str, "utf8"); | ||
}); | ||
} | ||
|
||
async function getDeviceTransactionConfig(families) { | ||
const outpath = path.join("generated", "deviceTransactionConfig.ts"); | ||
let imports = ``; | ||
let exprts = `export type ExtraDeviceTransactionField =`; | ||
for (const family of families) { | ||
const p = path.join("families", family, "deviceTransactionConfig.ts"); | ||
if (fs.existsSync(p)) { | ||
const file = await fs.promises.readFile(p, "utf8"); | ||
const hasExports = file.includes( | ||
"export type ExtraDeviceTransactionField" | ||
); | ||
if (hasExports) { | ||
imports += `import { ExtraDeviceTransactionField as ExtraDeviceTransactionField_${family} } from "../families/${family}/deviceTransactionConfig"; | ||
`; | ||
exprts += ` | ||
| ExtraDeviceTransactionField_${family}`; | ||
} | ||
} | ||
} | ||
|
||
const str = `${imports} | ||
${exprts}; | ||
`; | ||
|
||
await fs.promises.appendFile(outpath, str, "utf8"); | ||
} | ||
|
||
async function genTypesFile(families) { | ||
const outpath = path.join("generated", "types.ts"); | ||
let imprts = ``; | ||
let exprtsT = `export type Transaction =`; | ||
let exprtsTRaw = `export type TransactionRaw =`; | ||
let exprtsStatus = `export type TransactionStatus =`; | ||
let exprtsStatusRaw = `export type TransactionStatusRaw =`; | ||
for (const family of families) { | ||
imprts += `import { Transaction as ${family}Transaction } from "../families/${family}/types"; | ||
import { TransactionRaw as ${family}TransactionRaw } from "../families/${family}/types"; | ||
import { TransactionStatus as ${family}TransactionStatus } from "../families/${family}/types; | ||
import { TransactionStatusRaw as ${family}TransactionStatusRaw } from "../families/${family}/types; | ||
`; | ||
exprtsT += ` | ||
| ${family}Transaction`; | ||
|
||
exprtsTRaw += ` | ||
| ${family}TransactionRaw`; | ||
|
||
exprtsStatus += ` | ||
| ${family}TransactionStatus`; | ||
|
||
exprtsStatusRaw += ` | ||
| ${family}TransactionStatusRaw`; | ||
} | ||
|
||
exprtsT += `; | ||
`; | ||
exprtsTRaw += `; | ||
`; | ||
exprtsStatus += `; | ||
`; | ||
exprtsStatusRaw += `; | ||
`; | ||
|
||
const str = `${imprts} | ||
${exprtsT} | ||
${exprtsTRaw} | ||
${exprtsStatus} | ||
${exprtsStatusRaw}`; | ||
|
||
await fs.promises.writeFile(outpath, str, "utf8"); | ||
} | ||
|
||
await genTarget(targets, families); | ||
await genTypesFile(families); | ||
await getDeviceTransactionConfig(families); |
Oops, something went wrong.