create-near-app 4.0.0-beta.1.0 → 4.0.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 +30 -24
- package/dist/app.js +35 -66
- package/dist/make.js +44 -38
- package/dist/messages.js +47 -24
- package/dist/package-json.js +81 -49
- package/dist/tracking.js +1 -1
- package/dist/types.js +4 -0
- package/dist/user-input.js +124 -42
- package/package.json +32 -35
- package/templates/contracts/assemblyscript/README.md +4 -4
- package/templates/contracts/assemblyscript/package.json +2 -2
- package/templates/contracts/js/README.md +23 -0
- package/templates/contracts/js/package.json +5 -5
- package/templates/contracts/js/src/contract.ts +8 -6
- package/templates/contracts/rust/README.md +3 -3
- package/templates/frontend/react/frontend/App.js +5 -2
- package/templates/frontend/react/frontend/assets/global.css +62 -4
- package/templates/frontend/react/frontend/package.json +16 -16
- package/templates/frontend/react/frontend/ui-components.js +1 -1
- package/templates/frontend/vanilla/frontend/assets/global.css +64 -4
- package/templates/frontend/vanilla/frontend/index.html +8 -5
- package/templates/frontend/vanilla/frontend/package.json +5 -5
- package/templates/integration-tests/overrides/js-contract/js-tests/src/main.ava.ts +46 -0
- package/templates/integration-tests/overrides/js-contract/rust-tests/src/tests.rs +74 -0
- package/templates/integration-tests/{classic-tests → shared/js-tests}/ava.config.cjs +0 -0
- package/templates/integration-tests/{classic-tests → shared/js-tests}/package.json +6 -6
- package/templates/integration-tests/{workspaces-tests/ts → shared/js-tests}/src/main.ava.ts +0 -1
- package/templates/integration-tests/{workspaces-tests/rs → shared/rust-tests}/Cargo.toml +1 -1
- package/templates/integration-tests/{workspaces-tests/rs → shared/rust-tests}/src/tests.rs +2 -2
- package/templates/shared/.gitpod.yml +2 -2
- package/templates/shared/README.md +10 -10
- package/dist/checks.js +0 -34
- package/templates/contracts/assemblyscript/yarn.lock +0 -2952
- package/templates/contracts/js/yarn.lock +0 -2534
- package/templates/frontend/react/frontend/yarn.lock +0 -4550
- package/templates/frontend/vanilla/frontend/yarn.lock +0 -2328
- package/templates/integration-tests/classic-tests/src/config.ts +0 -34
- package/templates/integration-tests/classic-tests/src/main.ava.ts +0 -32
- package/templates/integration-tests/classic-tests/yarn.lock +0 -1323
- package/templates/integration-tests/workspaces-tests/ts/ava.config.cjs +0 -9
- package/templates/integration-tests/workspaces-tests/ts/package.json +0 -17
- package/templates/integration-tests/workspaces-tests/ts/yarn.lock +0 -1653
package/README.md
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
# Create NEAR App
|
|
2
2
|
===============
|
|
3
3
|
[](https://gitpod.io/#https://github.com/nearprotocol/create-near-app)
|
|
4
4
|
|
|
5
5
|
Quickly build apps backed by the [NEAR](https://near.org) blockchain
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
Prerequisites
|
|
9
|
-
=============
|
|
8
|
+
## Prerequisites
|
|
10
9
|
|
|
11
10
|
Make sure you have a [current version of Node.js](https://nodejs.org/en/about/releases/) installed – we are targeting versions `16+`.
|
|
12
11
|
|
|
13
12
|
Read about other [prerequisites](https://docs.near.org/develop/prerequisites) in our docs.
|
|
14
13
|
|
|
15
|
-
Getting Started
|
|
16
|
-
===============
|
|
17
|
-
|
|
18
|
-
To create a new NEAR project with default settings:
|
|
14
|
+
## Getting Started
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
To create a new NEAR project run this and follow interactive prompts:
|
|
21
17
|
|
|
22
18
|
npx create-near-app
|
|
23
19
|
|
|
20
|
+
Follow the instructions in the README.md in the project you just created! 🚀
|
|
21
|
+
|
|
24
22
|
You can create contracts written in:
|
|
25
23
|
|
|
26
|
-
- [Rust](https://docs.near.org/develop/prerequisites)
|
|
27
24
|
- [JavaScript](https://docs.near.org/develop/quickstart-guide)
|
|
25
|
+
- [Rust](https://docs.near.org/develop/prerequisites)
|
|
28
26
|
- AssemblyScript
|
|
29
27
|
|
|
30
28
|
You can create a frontend template in:
|
|
@@ -32,31 +30,41 @@ You can create a frontend template in:
|
|
|
32
30
|
- [React](https://reactjs.org/)
|
|
33
31
|
- Vanilla JavaScript
|
|
34
32
|
|
|
33
|
+
For testing we use a sandboxed environment of NEAR (called Workspaces).
|
|
34
|
+
You can write the tests in JavaScript or Rust.
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
=====================
|
|
36
|
+
### Using CLI arguments to run `create-near-app`
|
|
38
37
|
|
|
39
|
-
|
|
38
|
+
This CLI supports arguments to skip interactive prompts:
|
|
39
|
+
|
|
40
|
+
```shell
|
|
41
|
+
npx create-near-app
|
|
42
|
+
<project-name>
|
|
43
|
+
--contract js|rust|assemblyscript
|
|
44
|
+
--frontend vanilla|react|none
|
|
45
|
+
--tests js|rust
|
|
46
|
+
--install
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Use `--install` to automatically install dependencies from all `package.json` files.
|
|
40
50
|
|
|
51
|
+
When using arguments, all arguments are required, except for `--install`.
|
|
41
52
|
|
|
42
|
-
Getting Help
|
|
43
|
-
============
|
|
53
|
+
## Getting Help
|
|
44
54
|
|
|
45
55
|
Check out our [documentation](https://docs.near.org) or chat with us on [Discord](http://near.chat). We'd love to hear from you!
|
|
46
56
|
|
|
47
57
|
|
|
48
|
-
Contributing
|
|
49
|
-
============
|
|
58
|
+
## Contributing to `create-near-app`
|
|
50
59
|
|
|
51
60
|
To make changes to `create-near-app` itself:
|
|
52
61
|
|
|
53
62
|
* clone the repository (Windows users, [use `git clone -c core.symlinks=true`](https://stackoverflow.com/a/42137273/249801))
|
|
54
63
|
* in your terminal, enter one of the folders inside `templates`, such as `templates/vanilla`
|
|
55
|
-
* now you can run `
|
|
64
|
+
* now you can run `npm install` to install dependencies and `npm run dev` to run the local development server, just like you can in a new app created with `create-near-app`
|
|
56
65
|
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
---------------------
|
|
67
|
+
#### About commit messages
|
|
60
68
|
|
|
61
69
|
`create-near-app` uses semantic versioning and auto-generates nice release notes & a changelog all based off of the commits. We do this by enforcing [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/). In general the pattern mostly looks like this:
|
|
62
70
|
|
|
@@ -73,8 +81,7 @@ Real world examples can look like this:
|
|
|
73
81
|
If your change should show up in release notes as a feature, use `feat:`. If it should show up as a fix, use `fix:`. Otherwise, you probably want `refactor:` or `chore:`. [More info](https://github.com/conventional-changelog/commitlint/#what-is-commitlint)
|
|
74
82
|
|
|
75
83
|
|
|
76
|
-
Deploy
|
|
77
|
-
------
|
|
84
|
+
#### Deploy `create-near-app`
|
|
78
85
|
|
|
79
86
|
If you want to deploy a new version, you will need two prerequisites:
|
|
80
87
|
|
|
@@ -85,13 +92,12 @@ If you want to deploy a new version, you will need two prerequisites:
|
|
|
85
92
|
|
|
86
93
|
Then run one script:
|
|
87
94
|
|
|
88
|
-
|
|
95
|
+
npm run release
|
|
89
96
|
|
|
90
97
|
Or just `release-it`
|
|
91
98
|
|
|
92
99
|
|
|
93
|
-
License
|
|
94
|
-
=======
|
|
100
|
+
## License
|
|
95
101
|
|
|
96
102
|
This repository is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
|
|
97
103
|
See [LICENSE](LICENSE) and [LICENSE-APACHE](LICENSE-APACHE) for details.
|
package/dist/app.js
CHANGED
|
@@ -1,74 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
30
|
const make_1 = require("./make");
|
|
9
|
-
const tracking_1 = require("./tracking");
|
|
10
|
-
const semver_1 = __importDefault(require("semver"));
|
|
11
31
|
const user_input_1 = require("./user-input");
|
|
12
|
-
const
|
|
13
|
-
(async function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const args = await (0, user_input_1.getUserArgs)();
|
|
17
|
-
let { install } = args;
|
|
18
|
-
const argsValid = (0, user_input_1.validateUserArgs)(args);
|
|
19
|
-
// sanbox should be well supported by now, assemblyscript will be deprecated soon
|
|
20
|
-
// we explicitly take user's input: --no-sandbox => false, otherwise true
|
|
21
|
-
const supportsSandbox = args.sandbox;
|
|
22
|
-
if (argsValid === 'error') {
|
|
23
|
-
messages_1.show.argsError();
|
|
32
|
+
const show = __importStar(require("./messages"));
|
|
33
|
+
(async function () {
|
|
34
|
+
const promptResult = await (0, user_input_1.promptAndGetConfig)();
|
|
35
|
+
if (promptResult === null) {
|
|
24
36
|
return;
|
|
25
37
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
messages_1.show.welcome();
|
|
30
|
-
// Check node.js version
|
|
31
|
-
const current = process.version;
|
|
32
|
-
const supported = require('../package.json').engines.node;
|
|
33
|
-
if (!semver_1.default.satisfies(current, supported)) {
|
|
34
|
-
messages_1.show.unsupportedNodeVersion(supported);
|
|
35
|
-
// TODO: track unsupported versions
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
// Get user input
|
|
39
|
-
if (config === null) {
|
|
40
|
-
const userInput = await (0, user_input_1.showUserPrompts)();
|
|
41
|
-
configIsFromPrompts = true;
|
|
42
|
-
if (!(0, user_input_1.userAnswersAreValid)(userInput)) {
|
|
43
|
-
throw new Error(`Invalid prompt. ${JSON.stringify(userInput)}`);
|
|
44
|
-
}
|
|
45
|
-
config = userInput;
|
|
46
|
-
}
|
|
47
|
-
const { frontend, contract, projectName } = config;
|
|
48
|
-
(0, tracking_1.trackUsage)(frontend, contract);
|
|
49
|
-
let projectPath = `${process.cwd()}/${projectName}`;
|
|
50
|
-
// If dir exists keep asking user
|
|
51
|
-
if (fs_1.default.existsSync(projectPath)) {
|
|
52
|
-
if (!configIsFromPrompts) {
|
|
53
|
-
messages_1.show.directoryExists(projectPath);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
while (fs_1.default.existsSync(projectPath)) {
|
|
58
|
-
messages_1.show.directoryExists(projectPath);
|
|
59
|
-
const { projectName: newProjectName } = await (0, user_input_1.showProjectNamePrompt)();
|
|
60
|
-
projectPath = `${process.cwd()}/${newProjectName}`;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Create the project
|
|
38
|
+
const { config: { projectName, contract, frontend, tests, install, }, projectPath, } = promptResult;
|
|
39
|
+
show.creatingApp();
|
|
65
40
|
let createSuccess;
|
|
66
41
|
try {
|
|
67
42
|
createSuccess = await (0, make_1.createProject)({
|
|
68
43
|
contract,
|
|
69
44
|
frontend,
|
|
45
|
+
tests,
|
|
70
46
|
projectName,
|
|
71
|
-
supportsSandbox,
|
|
72
47
|
verbose: false,
|
|
73
48
|
rootDir: path_1.default.resolve(__dirname, '../templates'),
|
|
74
49
|
projectPath,
|
|
@@ -78,21 +53,15 @@ const messages_1 = require("./messages");
|
|
|
78
53
|
console.error(e);
|
|
79
54
|
createSuccess = false;
|
|
80
55
|
}
|
|
56
|
+
if (install) {
|
|
57
|
+
await (0, make_1.runDepsInstall)(projectPath);
|
|
58
|
+
}
|
|
81
59
|
if (createSuccess) {
|
|
82
|
-
|
|
60
|
+
show.setupSuccess(projectPath, contract, frontend, install);
|
|
83
61
|
}
|
|
84
62
|
else {
|
|
85
|
-
|
|
63
|
+
show.setupFailed();
|
|
86
64
|
return;
|
|
87
65
|
}
|
|
88
|
-
if (install) {
|
|
89
|
-
await (0, make_1.runDepsInstall)(projectPath);
|
|
90
|
-
}
|
|
91
|
-
else if (configIsFromPrompts) {
|
|
92
|
-
const { depsInstall } = await (0, user_input_1.showDepsInstallPrompt)();
|
|
93
|
-
if (depsInstall) {
|
|
94
|
-
await (0, make_1.runDepsInstall)(projectPath);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
66
|
})();
|
|
98
67
|
//# sourceMappingURL=app.js.map
|
package/dist/make.js
CHANGED
|
@@ -1,35 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.runDepsInstall = exports.copyDir = exports.renameFile = exports.createFiles = exports.createProject = void 0;
|
|
7
|
-
const
|
|
30
|
+
const show = __importStar(require("./messages"));
|
|
8
31
|
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
9
32
|
const fs_1 = __importDefault(require("fs"));
|
|
10
33
|
const ncp_1 = require("ncp");
|
|
11
34
|
const path_1 = __importDefault(require("path"));
|
|
12
|
-
const checks_1 = require("./checks");
|
|
13
35
|
const package_json_1 = require("./package-json");
|
|
14
|
-
|
|
15
|
-
async function createProject({ contract, frontend, projectPath, projectName, verbose, rootDir, supportsSandbox }) {
|
|
16
|
-
// Make language specific checks
|
|
17
|
-
let preMessagePass = (0, checks_1.preMessage)({ contract, projectName, frontend, projectPath, verbose, rootDir, supportsSandbox });
|
|
18
|
-
if (!preMessagePass) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
messages_1.show.creatingApp();
|
|
36
|
+
async function createProject({ contract, frontend, tests, projectPath, projectName, verbose, rootDir }) {
|
|
22
37
|
// Create files in the project folder
|
|
23
|
-
await createFiles({ contract, frontend, projectName, projectPath, verbose, rootDir
|
|
38
|
+
await createFiles({ contract, frontend, projectName, tests, projectPath, verbose, rootDir });
|
|
24
39
|
// Create package.json
|
|
25
|
-
const packageJson = (0, package_json_1.buildPackageJson)({ contract, frontend,
|
|
40
|
+
const packageJson = (0, package_json_1.buildPackageJson)({ contract, frontend, tests, projectName });
|
|
26
41
|
fs_1.default.writeFileSync(path_1.default.resolve(projectPath, 'package.json'), Buffer.from(JSON.stringify(packageJson, null, 2)));
|
|
27
|
-
// Run language-specific post check
|
|
28
|
-
(0, checks_1.postMessage)({ contract, frontend, projectName, projectPath, verbose, rootDir, supportsSandbox });
|
|
29
42
|
return true;
|
|
30
43
|
}
|
|
31
44
|
exports.createProject = createProject;
|
|
32
|
-
async function createFiles({ contract, frontend, projectPath, verbose, rootDir
|
|
45
|
+
async function createFiles({ contract, frontend, tests, projectPath, verbose, rootDir }) {
|
|
33
46
|
// skip build artifacts and symlinks
|
|
34
47
|
const skip = ['.cache', 'dist', 'out', 'node_modules'];
|
|
35
48
|
// copy frontend
|
|
@@ -46,27 +59,20 @@ async function createFiles({ contract, frontend, projectPath, verbose, rootDir,
|
|
|
46
59
|
verbose,
|
|
47
60
|
skip: skip.map(f => path_1.default.join(contractSourceDir, f))
|
|
48
61
|
});
|
|
49
|
-
// copy tests
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (supportsSandbox) {
|
|
53
|
-
switch (contract) {
|
|
54
|
-
case 'js':
|
|
55
|
-
case 'assemblyscript':
|
|
56
|
-
sourceTestDir = path_1.default.resolve(sourceTestDir, testFramework, 'ts');
|
|
57
|
-
break;
|
|
58
|
-
case 'rust':
|
|
59
|
-
sourceTestDir = path_1.default.resolve(sourceTestDir, 'workspaces-tests/rs');
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
sourceTestDir = path_1.default.resolve(sourceTestDir, 'classic-tests');
|
|
65
|
-
}
|
|
66
|
-
await copyDir(sourceTestDir, `${projectPath}/integration-tests/`, {
|
|
62
|
+
// copy tests - shared files
|
|
63
|
+
let sourceTestSharedDir = path_1.default.resolve(`${rootDir}/integration-tests/shared/${tests}-tests`);
|
|
64
|
+
await copyDir(sourceTestSharedDir, `${projectPath}/integration-tests/`, {
|
|
67
65
|
verbose,
|
|
68
|
-
skip: skip.map(f => path_1.default.join(
|
|
66
|
+
skip: skip.map(f => path_1.default.join(sourceTestSharedDir, f))
|
|
69
67
|
});
|
|
68
|
+
// copy tests - overrides files
|
|
69
|
+
let sourceTestOverridesDir = path_1.default.resolve(`${rootDir}/integration-tests/overrides/${contract}-contract/${tests}-tests`);
|
|
70
|
+
if (fs_1.default.existsSync(sourceTestOverridesDir)) {
|
|
71
|
+
await copyDir(sourceTestOverridesDir, `${projectPath}/integration-tests/`, {
|
|
72
|
+
verbose,
|
|
73
|
+
skip: skip.map(f => path_1.default.join(sourceTestOverridesDir, f))
|
|
74
|
+
});
|
|
75
|
+
}
|
|
70
76
|
// add .gitignore
|
|
71
77
|
await (0, exports.renameFile)(`${projectPath}/near.gitignore`, `${projectPath}/.gitignore`);
|
|
72
78
|
}
|
|
@@ -112,14 +118,14 @@ function copyDir(source, dest, { skip, verbose }) {
|
|
|
112
118
|
}
|
|
113
119
|
exports.copyDir = copyDir;
|
|
114
120
|
async function runDepsInstall(projectPath) {
|
|
115
|
-
|
|
116
|
-
const npmCommandArgs = ['deps-install'];
|
|
117
|
-
await new Promise((resolve, reject) => (0, cross_spawn_1.default)('
|
|
121
|
+
show.depsInstall();
|
|
122
|
+
const npmCommandArgs = ['run', 'deps-install'];
|
|
123
|
+
await new Promise((resolve, reject) => (0, cross_spawn_1.default)('npm', npmCommandArgs, {
|
|
118
124
|
cwd: projectPath,
|
|
119
125
|
stdio: 'inherit',
|
|
120
126
|
}).on('close', (code) => {
|
|
121
127
|
if (code !== 0) {
|
|
122
|
-
|
|
128
|
+
show.depsInstallError();
|
|
123
129
|
reject(code);
|
|
124
130
|
}
|
|
125
131
|
else {
|
package/dist/messages.js
CHANGED
|
@@ -3,44 +3,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.depsInstallError = exports.depsInstall = exports.creatingApp = exports.directoryExists = exports.windowsWarning = exports.unsupportedNodeVersion = exports.argsError = exports.setupSuccess = exports.successFrontendToText = exports.successContractToText = exports.setupFailed = exports.welcome = exports.show = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
8
|
const tracking_1 = require("./tracking");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
if (process.env.NEAR_NO_COLOR) {
|
|
10
|
+
chalk_1.default.level = 0;
|
|
11
|
+
}
|
|
12
|
+
const show = (...args) => console.log(...args);
|
|
13
|
+
exports.show = show;
|
|
14
|
+
const welcome = () => (0, exports.show)((0, chalk_1.default) `{blue ======================================================}
|
|
12
15
|
👋 {bold {green Welcome to NEAR!}} Learn more: https://docs.near.org/
|
|
13
16
|
🔧 Let's get your dApp ready.
|
|
14
17
|
{blue ======================================================}
|
|
15
18
|
(${tracking_1.trackingMessage})
|
|
16
19
|
`);
|
|
17
|
-
|
|
20
|
+
exports.welcome = welcome;
|
|
21
|
+
const setupFailed = () => (0, exports.show)((0, chalk_1.default) `{bold {red ==========================================}}
|
|
18
22
|
{red ⛔️ There was a problem during NEAR project setup}.
|
|
19
23
|
Please refer to https://github.com/near/create-near-app README to troubleshoot.
|
|
20
24
|
Notice: some platforms aren't supported (yet).
|
|
21
25
|
{bold {red ==========================================}}`);
|
|
26
|
+
exports.setupFailed = setupFailed;
|
|
22
27
|
const successContractToText = (contract) => (0, chalk_1.default) `with a smart contract in {bold ${contract === 'rust' ? 'Rust' : contract === 'js' ? 'JavaScript' : 'AssemblyScript'}}`;
|
|
28
|
+
exports.successContractToText = successContractToText;
|
|
23
29
|
const successFrontendToText = (frontend) => frontend === 'none' ? '' : (0, chalk_1.default) ` and a frontend template${frontend === 'react' ? (0, chalk_1.default) `{bold in React.js}` : ''}`;
|
|
24
|
-
|
|
30
|
+
exports.successFrontendToText = successFrontendToText;
|
|
31
|
+
const setupSuccess = (projectName, contract, frontend, install) => (0, exports.show)((0, chalk_1.default) `
|
|
32
|
+
{green ======================================================}
|
|
25
33
|
✅ Success! Created '${projectName}'
|
|
26
|
-
${successContractToText(contract)}${successFrontendToText(frontend)}.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
{blue
|
|
31
|
-
|
|
34
|
+
${(0, exports.successContractToText)(contract)}${(0, exports.successFrontendToText)(frontend)}.
|
|
35
|
+
${contract === 'rust' ? (0, chalk_1.default) `🦀 If you are new to Rust please visit {bold {green https://www.rust-lang.org }}\n` : ''}
|
|
36
|
+
{bold {bgYellow {black Your next steps}}}:
|
|
37
|
+
- {inverse Navigate to your project}:
|
|
38
|
+
{blue cd {bold ${projectName}}}
|
|
39
|
+
${!install ? (0, chalk_1.default) `- {inverse Install all dependencies}
|
|
40
|
+
{blue npm {bold run deps-install}}` : 'Then:'}
|
|
41
|
+
- {inverse Test your contract} in NEAR SandBox:
|
|
42
|
+
{blue npm {bold test}}
|
|
43
|
+
- {inverse Deploy your contract} to NEAR TestNet with a temporary dev account:
|
|
44
|
+
{blue npm {bold run deploy}}
|
|
45
|
+
${frontend !== 'none' ? (0, chalk_1.default) `- {inverse Start your frontend}:
|
|
46
|
+
{blue npm {bold start}}\n` : ''}
|
|
47
|
+
🧠 Read {bold {greenBright README.md}} to explore further.`);
|
|
48
|
+
exports.setupSuccess = setupSuccess;
|
|
49
|
+
const argsError = () => (0, exports.show)((0, chalk_1.default) `{red Arguments error}
|
|
32
50
|
Run {blue npx create-near-app} without arguments, or use:
|
|
33
|
-
npx create-near-app <projectName> --contract rust|js|assemblyscript --frontend react|vanilla|none`);
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
|
|
51
|
+
npx create-near-app <projectName> --contract rust|js|assemblyscript --frontend react|vanilla|none --tests js|rust`);
|
|
52
|
+
exports.argsError = argsError;
|
|
53
|
+
const unsupportedNodeVersion = (supported) => (0, exports.show)((0, chalk_1.default) `{red We support node.js version ${supported} or later}`);
|
|
54
|
+
exports.unsupportedNodeVersion = unsupportedNodeVersion;
|
|
55
|
+
const windowsWarning = () => (0, exports.show)((0, chalk_1.default) `{bgYellow {black Notice: On Win32 please use WSL (Windows Subsystem for Linux).}}
|
|
56
|
+
https://docs.microsoft.com/en-us/windows/wsl/install
|
|
57
|
+
Exiting now.`);
|
|
58
|
+
exports.windowsWarning = windowsWarning;
|
|
59
|
+
const directoryExists = (dirName) => (0, exports.show)((0, chalk_1.default) `{red This directory already exists! ${dirName}}`);
|
|
60
|
+
exports.directoryExists = directoryExists;
|
|
61
|
+
const creatingApp = () => (0, exports.show)((0, chalk_1.default) `\nCreating a new {bold NEAR dApp}`);
|
|
62
|
+
exports.creatingApp = creatingApp;
|
|
63
|
+
const depsInstall = () => (0, exports.show)((0, chalk_1.default) `
|
|
64
|
+
{green Installing dependencies in a few folders, this might take a while.}
|
|
39
65
|
`);
|
|
40
|
-
|
|
41
|
-
exports.show
|
|
42
|
-
|
|
43
|
-
unsupportedNodeVersion, directoryExists, creatingApp,
|
|
44
|
-
depsInstall, depsInstallError,
|
|
45
|
-
};
|
|
66
|
+
exports.depsInstall = depsInstall;
|
|
67
|
+
const depsInstallError = () => (0, exports.show)(chalk_1.default.red('Error installing NEAR project dependencies'));
|
|
68
|
+
exports.depsInstallError = depsInstallError;
|
|
46
69
|
//# sourceMappingURL=messages.js.map
|