From 131cf971e0909d3ed586518331141749201ce631 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bahdanau Date: Tue, 18 Jun 2024 10:15:36 +0300 Subject: [PATCH 1/3] Add scripts subdirectories support --- src/types/file.ts | 4 ++++ src/utils.ts | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 src/types/file.ts diff --git a/src/types/file.ts b/src/types/file.ts new file mode 100644 index 0000000..a2e607e --- /dev/null +++ b/src/types/file.ts @@ -0,0 +1,4 @@ +export type File = { + name: string; + path: string; +}; diff --git a/src/utils.ts b/src/utils.ts index 1f22602..475a00e 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,6 +3,7 @@ import path from 'path'; import fs from 'fs/promises'; import { UIProvider } from './ui/UIProvider'; import { SCRIPTS_DIR, WRAPPERS_DIR } from './paths'; +import { File } from './types/file'; export const tonDeepLink = (address: Address, amount: bigint, body?: Cell, stateInit?: Cell) => `ton://transfer/${address.toString({ @@ -34,15 +35,22 @@ export function oneOrZeroOf(opti const compileEnd = '.compile.ts'; -export const findCompiles = async () => +export const findCompiles = async (): Promise => (await fs.readdir(WRAPPERS_DIR)) .filter((f) => f.endsWith(compileEnd)) .map((f) => ({ path: path.join(WRAPPERS_DIR, f), name: f.slice(0, f.length - compileEnd.length) })); -export const findScripts = async () => - (await fs.readdir(SCRIPTS_DIR)) - .filter((f) => f.endsWith('.ts')) - .map((f) => ({ path: path.join(SCRIPTS_DIR, f), name: path.parse(f).name })); +export const findScripts = async (): Promise => { + const dirents = await fs.readdir(SCRIPTS_DIR, { recursive: true, withFileTypes: true }); + const scripts = dirents.filter((dirent) => dirent.isFile() && dirent.name.endsWith('.ts')); + + return scripts + .map((script) => ({ + name: path.join(script.path.slice(SCRIPTS_DIR.length), script.name), + path: path.join(SCRIPTS_DIR, script.path, script.name), + })) + .sort((a, b) => (a.name >= b.name ? 1 : -1)); +}; export async function selectOption( options: { name: string; value: string }[], @@ -64,14 +72,14 @@ export async function selectOption( } export async function selectFile( - files: { name: string; path: string }[], + files: File[], opts: { ui: UIProvider; hint?: string; import?: boolean; }, ) { - let selected: { name: string; path: string }; + let selected: File; if (opts.hint) { const found = files.find((f) => f.name.toLowerCase() === opts.hint?.toLowerCase()); From 1523635ade244d7963a164df43162f900ca41c93 Mon Sep 17 00:00:00 2001 From: Aliaksandr Bahdanau Date: Tue, 18 Jun 2024 10:18:59 +0300 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 6 ++++++ package.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdef360..ab0823b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.22.0] - 2024-06-18 + +### Added + +- Added support for scripts in subdirectories, for example `scripts/counter/deploy.ts` + ## [0.21.0] - 2024-05-27 ### Changed diff --git a/package.json b/package.json index 493c2a2..632b89a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ton/blueprint", - "version": "0.21.0", + "version": "0.22.0", "description": "Framework for development of TON smart contracts", "main": "dist/index.js", "bin": "./dist/cli/cli.js", From da8f1a10b77d0d63672232d41807d065bd712cd0 Mon Sep 17 00:00:00 2001 From: krigga Date: Mon, 24 Jun 2024 16:16:03 +0300 Subject: [PATCH 3/3] chore: remove version bump --- CHANGELOG.md | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab0823b..8a7aa26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.22.0] - 2024-06-18 +## Unreleased ### Added diff --git a/package.json b/package.json index 632b89a..493c2a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ton/blueprint", - "version": "0.22.0", + "version": "0.21.0", "description": "Framework for development of TON smart contracts", "main": "dist/index.js", "bin": "./dist/cli/cli.js",