create-ton 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,21 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.6.0] - 2023-08-08
9
+
10
+ ### Added
11
+
12
+ - Added flags `--contractName` and `--type` to allow fully non-interactive runs
13
+ - Added scripts `start` and `build` to the template
14
+
15
+ ### Changed
16
+
17
+ - Updated blueprint to 0.12.0, test-utils to 0.3.0
18
+
19
+ ### Removed
20
+
21
+ - Removed license from the template
22
+
8
23
  ## [0.5.0] - 2023-06-06
9
24
 
10
25
  ### Changed
package/dist/cli.js CHANGED
@@ -8,52 +8,62 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  const child_process_1 = require("child_process");
10
10
  const inquirer_1 = __importDefault(require("inquirer"));
11
+ const arg_1 = __importDefault(require("arg"));
11
12
  const chalk_1 = __importDefault(require("chalk"));
12
13
  const FILES_WITH_NAME_TEMPLATE = ['package.json', 'README.md'];
13
14
  const NAME_TEMPLATE = '{{name}}';
15
+ const VARIANT_CHOICES = [
16
+ {
17
+ name: 'An empty contract (FunC)',
18
+ value: 'func-empty',
19
+ },
20
+ {
21
+ name: 'A simple counter contract (FunC)',
22
+ value: 'func-counter',
23
+ },
24
+ {
25
+ name: 'An empty contract (TACT)',
26
+ value: 'tact-empty',
27
+ },
28
+ {
29
+ name: 'A simple counter contract (TACT)',
30
+ value: 'tact-counter',
31
+ },
32
+ ];
14
33
  async function main() {
15
34
  console.log();
16
- const name = process.argv.length > 2
17
- ? process.argv[2]
18
- : (await inquirer_1.default.prompt({
35
+ const localArgs = (0, arg_1.default)({
36
+ '--type': String,
37
+ '--contractName': String,
38
+ });
39
+ const name = localArgs._[0] ||
40
+ (await inquirer_1.default.prompt({
19
41
  name: 'name',
20
42
  message: 'Project name',
21
43
  })).name.trim();
22
44
  if (name.length === 0)
23
45
  throw new Error('Cannot initialize a project with an empty name');
24
- const contractName = (await inquirer_1.default.prompt({
25
- name: 'contractName',
26
- message: 'First created contract name (PascalCase)',
27
- })).contractName.trim();
46
+ const contractName = localArgs['--contractName'] ||
47
+ (await inquirer_1.default.prompt({
48
+ name: 'contractName',
49
+ message: 'First created contract name (PascalCase)',
50
+ })).contractName.trim();
28
51
  if (contractName.length === 0)
29
52
  throw new Error(`Cannot create a contract with an empty name`);
30
53
  if (contractName.toLowerCase() === 'contract' || !/^[A-Z][a-zA-Z0-9]*$/.test(contractName))
31
54
  throw new Error(`Cannot create a contract with the name '${contractName}'`);
32
- const { variant } = await inquirer_1.default.prompt([
33
- {
34
- name: 'variant',
35
- message: 'Choose the project template',
36
- type: 'list',
37
- choices: [
38
- {
39
- name: 'An empty contract (FunC)',
40
- value: 'func-empty',
41
- },
42
- {
43
- name: 'A simple counter contract (FunC)',
44
- value: 'func-counter',
45
- },
46
- {
47
- name: 'An empty contract (TACT)',
48
- value: 'tact-empty',
49
- },
50
- {
51
- name: 'A simple counter contract (TACT)',
52
- value: 'tact-counter',
53
- },
54
- ],
55
- },
56
- ]);
55
+ const argsVariant = VARIANT_CHOICES.map(e => e.value).indexOf(localArgs['--type'] || '') !== -1
56
+ ? localArgs['--type']
57
+ : undefined;
58
+ const variant = argsVariant ||
59
+ (await inquirer_1.default.prompt([
60
+ {
61
+ name: 'variant',
62
+ message: 'Choose the project template',
63
+ type: 'list',
64
+ choices: VARIANT_CHOICES,
65
+ },
66
+ ])).variant;
57
67
  await fs_extra_1.default.mkdir(name);
58
68
  const steps = 3;
59
69
  console.log(`\n[1/${steps}] Copying files...`);
@@ -24,6 +24,3 @@
24
24
  ### Add a new contract
25
25
 
26
26
  `npx blueprint create ContractName` or `yarn blueprint create ContractName`
27
-
28
- # License
29
- MIT
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "{{name}}",
3
3
  "version": "0.0.1",
4
- "license": "MIT",
5
4
  "scripts": {
5
+ "start": "blueprint run",
6
+ "build": "blueprint build",
6
7
  "test": "jest"
7
8
  },
8
9
  "devDependencies": {
9
- "@ton-community/blueprint": "^0.10.0",
10
+ "@ton-community/blueprint": "^0.12.0",
10
11
  "@ton-community/sandbox": "^0.11.0",
11
- "@ton-community/test-utils": "^0.2.0",
12
+ "@ton-community/test-utils": "^0.3.0",
12
13
  "@types/jest": "^29.5.0",
13
14
  "@types/node": "^20.2.5",
14
15
  "jest": "^29.5.0",
package/package.json CHANGED
@@ -1,32 +1,32 @@
1
1
  {
2
- "name": "create-ton",
3
- "version": "0.5.0",
4
- "license": "MIT",
5
- "description": "Tool to quickly create TON projects",
6
- "author": "TonTech",
7
- "repository": {
8
- "type": "git",
9
- "url": "git+https://github.com/ton-community/create-ton.git"
10
- },
11
- "files": [
12
- "dist/**/*"
13
- ],
14
- "bin": {
15
- "create-ton": "./dist/cli.js"
16
- },
17
- "scripts": {
18
- "build": "rm -rf dist && tsc && cp -r template dist/template"
19
- },
20
- "devDependencies": {
21
- "@types/fs-extra": "^11.0.1",
22
- "@types/inquirer": "^8.2.6",
23
- "@types/node": "^20.2.5",
24
- "prettier": "^2.8.8",
25
- "typescript": "^4.9.5"
26
- },
27
- "dependencies": {
28
- "chalk": "^4.1.0",
29
- "fs-extra": "^11.1.1",
30
- "inquirer": "^8.2.5"
31
- }
32
- }
2
+ "name": "create-ton",
3
+ "version": "0.6.0",
4
+ "license": "MIT",
5
+ "description": "Tool to quickly create TON projects",
6
+ "author": "TonTech",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/ton-community/create-ton.git"
10
+ },
11
+ "files": [
12
+ "dist/**/*"
13
+ ],
14
+ "bin": "./dist/cli.js",
15
+ "scripts": {
16
+ "build": "rm -rf dist && tsc && cp -r template dist/template"
17
+ },
18
+ "devDependencies": {
19
+ "@types/fs-extra": "^11.0.1",
20
+ "@types/inquirer": "^8.2.6",
21
+ "@types/node": "^20.2.5",
22
+ "prettier": "^2.8.8",
23
+ "typescript": "^4.9.5"
24
+ },
25
+ "dependencies": {
26
+ "arg": "^5.0.2",
27
+ "chalk": "^4.1.0",
28
+ "fs-extra": "^11.1.1",
29
+ "inquirer": "^8.2.5"
30
+ },
31
+ "packageManager": "yarn@3.6.1"
32
+ }