create-ton 0.33.0 → 0.34.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/README.md +6 -2
- package/dist/main.js +29 -8
- package/dist/template/.vscode/extensions.json +3 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +11 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# npm create ton
|
|
2
2
|
|
|
3
|
+
> [!CAUTION]
|
|
4
|
+
> Deprecated. Use [Acton](https://ton-blockchain.github.io/acton/) instead.
|
|
5
|
+
|
|
3
6
|
This is an entry point script for the Blueprint development tool
|
|
4
7
|
|
|
5
8
|
## Usage
|
|
@@ -15,6 +18,7 @@ If you want to input data non-interactively (for example, in scripts), do:
|
|
|
15
18
|
```bash
|
|
16
19
|
npm create ton@latest -- project-dir --type first-contract-type --contractName FirstContractName
|
|
17
20
|
```
|
|
18
|
-
where `first-contract-type` can currently be one of `tolk-empty`, `tolk-counter`, `func-empty`, `func-counter`, `tact-empty`, `tact-counter`
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
where `first-contract-type` can currently be one of `tolk-empty`, `tolk-counter`, `func-empty` (deprecated), `func-counter` (deprecated), `tact-empty` (deprecated), `tact-counter` (deprecated)
|
|
23
|
+
|
|
24
|
+
For more details please go to https://ton-blockchain.github.io/acton/
|
package/dist/main.js
CHANGED
|
@@ -10,19 +10,29 @@ const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
|
10
10
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
11
11
|
const arg_1 = __importDefault(require("arg"));
|
|
12
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const utils_1 = require("./utils");
|
|
13
14
|
const FILES_WITH_NAME_TEMPLATE = ['package.json', 'README.md'];
|
|
14
15
|
const NAME_TEMPLATE = '{{name}}';
|
|
16
|
+
function sanitizeDefaultProjectName(name) {
|
|
17
|
+
return name.replace(/[^a-zA-Z0-9_-]+/g, '_');
|
|
18
|
+
}
|
|
19
|
+
function sanitizeContractName(name) {
|
|
20
|
+
const contractName = (0, utils_1.snakeToPascal)(name);
|
|
21
|
+
if (contractName.length === 0 || /^[A-Z]/.test(contractName))
|
|
22
|
+
return contractName;
|
|
23
|
+
return `Contract${contractName}`;
|
|
24
|
+
}
|
|
15
25
|
const VARIANT_CHOICES = [
|
|
16
26
|
{
|
|
17
27
|
name: 'An empty contract (Tolk)',
|
|
18
28
|
value: 'tolk-empty',
|
|
19
29
|
},
|
|
20
30
|
{
|
|
21
|
-
name: 'An empty contract (FunC)',
|
|
31
|
+
name: 'An empty contract (FunC, deprecated)',
|
|
22
32
|
value: 'func-empty',
|
|
23
33
|
},
|
|
24
34
|
{
|
|
25
|
-
name: 'An empty contract (Tact)',
|
|
35
|
+
name: 'An empty contract (Tact, deprecated)',
|
|
26
36
|
value: 'tact-empty',
|
|
27
37
|
},
|
|
28
38
|
{
|
|
@@ -30,15 +40,16 @@ const VARIANT_CHOICES = [
|
|
|
30
40
|
value: 'tolk-counter',
|
|
31
41
|
},
|
|
32
42
|
{
|
|
33
|
-
name: 'A simple counter contract (FunC)',
|
|
43
|
+
name: 'A simple counter contract (FunC, deprecated)',
|
|
34
44
|
value: 'func-counter',
|
|
35
45
|
},
|
|
36
46
|
{
|
|
37
|
-
name: 'A simple counter contract (Tact)',
|
|
47
|
+
name: 'A simple counter contract (Tact, deprecated)',
|
|
38
48
|
value: 'tact-counter',
|
|
39
49
|
},
|
|
40
50
|
];
|
|
41
51
|
async function main() {
|
|
52
|
+
printDeprecationNotice();
|
|
42
53
|
console.log();
|
|
43
54
|
const localArgs = (0, arg_1.default)({
|
|
44
55
|
'--type': String,
|
|
@@ -46,21 +57,27 @@ async function main() {
|
|
|
46
57
|
'--no-ci': Boolean, // whether to skip installation of dependendencies, git init
|
|
47
58
|
// and creation of the first contract via Blueprint
|
|
48
59
|
});
|
|
60
|
+
const defaultProjectName = sanitizeDefaultProjectName(path_1.default.basename(path_1.default.resolve('')));
|
|
49
61
|
const desiredProjectName = localArgs._[0] ||
|
|
50
62
|
(await inquirer_1.default.prompt({
|
|
51
63
|
name: 'name',
|
|
52
64
|
message: 'Project name',
|
|
65
|
+
default: defaultProjectName,
|
|
53
66
|
})).name.trim();
|
|
54
67
|
const projectPath = path_1.default.resolve(desiredProjectName);
|
|
55
68
|
const name = path_1.default.basename(projectPath);
|
|
56
|
-
if (name.length === 0)
|
|
69
|
+
if (desiredProjectName.length === 0 || name.length === 0) {
|
|
57
70
|
throw new Error('Cannot initialize a project with an empty name');
|
|
71
|
+
}
|
|
58
72
|
const noCi = localArgs['--no-ci'] ?? false;
|
|
59
|
-
const
|
|
73
|
+
const defaultContractName = sanitizeContractName(name);
|
|
74
|
+
const rawContractName = ((noCi ? 'NonExistent' : localArgs['--contractName']) ||
|
|
60
75
|
(await inquirer_1.default.prompt({
|
|
61
76
|
name: 'contractName',
|
|
62
77
|
message: 'First created contract name (PascalCase)',
|
|
63
|
-
|
|
78
|
+
default: defaultContractName,
|
|
79
|
+
})).contractName).trim();
|
|
80
|
+
const contractName = sanitizeContractName(rawContractName);
|
|
64
81
|
if (!noCi) {
|
|
65
82
|
if (contractName.length === 0)
|
|
66
83
|
throw new Error(`Cannot create a contract with an empty name`);
|
|
@@ -94,6 +111,7 @@ build
|
|
|
94
111
|
dist
|
|
95
112
|
.DS_Store
|
|
96
113
|
package.ts
|
|
114
|
+
.env
|
|
97
115
|
|
|
98
116
|
# VS Code
|
|
99
117
|
.vscode/*
|
|
@@ -203,6 +221,9 @@ function printResultingUsageDetails(desiredProjectName, noCi) {
|
|
|
203
221
|
console.log(chalk_1.default.greenBright(` > `) + chalk_1.default.cyanBright(`npx blueprint create AnotherContract`));
|
|
204
222
|
console.log(` create a new contract and all related necessary files`);
|
|
205
223
|
console.log(``);
|
|
206
|
-
|
|
224
|
+
printDeprecationNotice();
|
|
207
225
|
console.log(``);
|
|
208
226
|
}
|
|
227
|
+
function printDeprecationNotice() {
|
|
228
|
+
console.log(`${chalk_1.default.red('!')} Deprecated. Use https://ton-blockchain.github.io/acton/ instead.`);
|
|
229
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function snakeToPascal(str: string): string;
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.snakeToPascal = void 0;
|
|
4
|
+
function snakeToPascal(str) {
|
|
5
|
+
return str
|
|
6
|
+
.split(/[^a-zA-Z0-9]+/)
|
|
7
|
+
.filter(Boolean)
|
|
8
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1))
|
|
9
|
+
.join('');
|
|
10
|
+
}
|
|
11
|
+
exports.snakeToPascal = snakeToPascal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-ton",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Tool to quickly create TON projects",
|
|
6
6
|
"author": "TonTech",
|
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
"scripts": {
|
|
17
17
|
"lint": "eslint . --max-warnings 0",
|
|
18
18
|
"lint:fix": "eslint . --max-warnings 0 --fix",
|
|
19
|
+
"fmt": "prettier --write -l --cache .",
|
|
20
|
+
"fmt:check": "prettier --check --cache .",
|
|
19
21
|
"test": "jest src",
|
|
20
22
|
"build": "rm -rf dist && tsc && cp -r template dist/template"
|
|
21
23
|
},
|
|
@@ -37,5 +39,5 @@
|
|
|
37
39
|
"fs-extra": "^11.1.1",
|
|
38
40
|
"inquirer": "^8.2.5"
|
|
39
41
|
},
|
|
40
|
-
"packageManager": "yarn@
|
|
42
|
+
"packageManager": "yarn@4.17.0+sha512.c2957de2f9025ab14d63b24d0d8be1f1655810e22c341042c27f7ecd017b180ec12db73d69ac366d71b304ef9f069349ce462de96f04f8f1da317f4f762c95ae"
|
|
41
43
|
}
|