create-near-app 7.0.2-beta.0 → 7.0.3
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/dist/app.js +5 -0
- package/dist/messages.js +3 -3
- package/dist/user-input.js +16 -13
- package/package.json +1 -1
- package/templates/contracts/rs/Cargo.lock +6619 -0
- package/templates/contracts/rs/Cargo.toml +3 -3
- package/templates/contracts/rs/src/lib.rs +1 -1
- package/templates/contracts/rs/tests/test_basics.rs +6 -5
- package/templates/contracts/ts/package.json +4 -2
- package/templates/contracts/ts/src/contract.ts +5 -0
- package/templates/contracts/ts/yarn.lock +3290 -0
- package/templates/frontend/next-app/package.json +11 -7
- package/templates/frontend/next-app/src/wallets/near.js +42 -5
- package/templates/frontend/next-page/package.json +11 -7
- package/templates/frontend/next-page/src/wallets/near.js +42 -5
package/dist/app.js
CHANGED
|
@@ -27,10 +27,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const semver_1 = __importDefault(require("semver"));
|
|
30
31
|
const make_1 = require("./make");
|
|
31
32
|
const user_input_1 = require("./user-input");
|
|
32
33
|
const show = __importStar(require("./messages"));
|
|
33
34
|
(async function () {
|
|
35
|
+
const supportedNodeVersion = require('../package.json').engines.node;
|
|
36
|
+
if (!semver_1.default.satisfies(process.version, supportedNodeVersion)) {
|
|
37
|
+
return show.unsupportedNodeVersion(supportedNodeVersion);
|
|
38
|
+
}
|
|
34
39
|
const prompt = await (0, user_input_1.promptAndGetConfig)();
|
|
35
40
|
if (prompt === undefined)
|
|
36
41
|
return;
|
package/dist/messages.js
CHANGED
|
@@ -84,9 +84,9 @@ npx create-near-app <projectName> [--frontend next-app|next-page] [--contract rs
|
|
|
84
84
|
exports.argsError = argsError;
|
|
85
85
|
const unsupportedNodeVersion = (supported) => (0, exports.show)((0, chalk_1.default) `{red We support node.js version ${supported} or later}`);
|
|
86
86
|
exports.unsupportedNodeVersion = unsupportedNodeVersion;
|
|
87
|
-
const windowsWarning = () => (0, exports.show)((0, chalk_1.default) `{
|
|
88
|
-
https://docs.
|
|
89
|
-
|
|
87
|
+
const windowsWarning = () => (0, exports.show)((0, chalk_1.default) `{red Please use Windows Subsystem for Linux (WSL) to develop smart contracts}
|
|
88
|
+
{yellow Learn more here: https://docs.near.org/blog/getting-started-on-windows}
|
|
89
|
+
`);
|
|
90
90
|
exports.windowsWarning = windowsWarning;
|
|
91
91
|
const directoryExists = (dirName) => (0, exports.show)((0, chalk_1.default) `{red This directory already exists! ${dirName}}`);
|
|
92
92
|
exports.directoryExists = directoryExists;
|
package/dist/user-input.js
CHANGED
|
@@ -32,7 +32,6 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
32
32
|
const prompts_1 = __importDefault(require("prompts"));
|
|
33
33
|
const commander_1 = require("commander");
|
|
34
34
|
const show = __importStar(require("./messages"));
|
|
35
|
-
const semver_1 = __importDefault(require("semver"));
|
|
36
35
|
const tracking_1 = require("./tracking");
|
|
37
36
|
const fs_1 = __importDefault(require("fs"));
|
|
38
37
|
async function getUserArgs() {
|
|
@@ -40,18 +39,21 @@ async function getUserArgs() {
|
|
|
40
39
|
.argument('[projectName]')
|
|
41
40
|
.option('--frontend [next-page|next-app|none]')
|
|
42
41
|
.option('--contract [ts|rs|none]')
|
|
42
|
+
.option('--components')
|
|
43
43
|
.option('--install')
|
|
44
44
|
.addHelpText('after', 'You can create a frontend or a contract with tests');
|
|
45
45
|
commander_1.program.parse();
|
|
46
46
|
const options = commander_1.program.opts();
|
|
47
47
|
const [projectName] = commander_1.program.args;
|
|
48
|
-
const { contract, frontend, install } = options;
|
|
49
|
-
return { contract, frontend, components
|
|
48
|
+
const { contract, frontend, install, components } = options;
|
|
49
|
+
return { contract, frontend, components, projectName, install, error: undefined };
|
|
50
50
|
}
|
|
51
51
|
exports.getUserArgs = getUserArgs;
|
|
52
52
|
const appChoices = [
|
|
53
53
|
{ title: 'A Web App', description: 'A Web App that talks with Near contracts', value: 'gateway' },
|
|
54
|
-
{
|
|
54
|
+
{
|
|
55
|
+
title: 'A Smart Contract', description: 'A smart contract to be deployed in the Near Blockchain', value: 'contract',
|
|
56
|
+
},
|
|
55
57
|
];
|
|
56
58
|
const contractChoices = [
|
|
57
59
|
{ title: 'JS/TS Contract', description: 'A Near contract written in javascript/typescript', value: 'ts' },
|
|
@@ -113,25 +115,22 @@ async function getUserAnswers() {
|
|
|
113
115
|
if (app === 'gateway') {
|
|
114
116
|
// If gateway, ask for the framework to use
|
|
115
117
|
const { frontend, components, projectName, install } = await promptUser([frontendPrompt, componentsPrompt, namePrompts, npmPrompt]);
|
|
116
|
-
return { frontend, components, contract: 'none', projectName, install };
|
|
118
|
+
return { frontend, components, contract: 'none', projectName, install, error: undefined };
|
|
117
119
|
}
|
|
118
120
|
else {
|
|
121
|
+
// If platform is Window, return the error
|
|
122
|
+
if (process.platform === 'win32') {
|
|
123
|
+
return { frontend: 'none', components: false, contract: 'none', projectName: '', install: false, error: show.windowsWarning };
|
|
124
|
+
}
|
|
119
125
|
// If contract, ask for the language for the contract
|
|
120
126
|
let { contract } = await promptUser(contractPrompt);
|
|
121
127
|
const { projectName } = await promptUser(namePrompts);
|
|
122
128
|
const install = contract === 'ts' ? (await promptUser(npmPrompt)).install : false;
|
|
123
|
-
return { frontend: 'none', components: false, contract, projectName, install };
|
|
129
|
+
return { frontend: 'none', components: false, contract, projectName, install, error: undefined };
|
|
124
130
|
}
|
|
125
131
|
}
|
|
126
132
|
exports.getUserAnswers = getUserAnswers;
|
|
127
133
|
async function promptAndGetConfig() {
|
|
128
|
-
const supportedNodeVersion = require('../package.json').engines.node;
|
|
129
|
-
if (!semver_1.default.satisfies(process.version, supportedNodeVersion)) {
|
|
130
|
-
return show.unsupportedNodeVersion(supportedNodeVersion);
|
|
131
|
-
}
|
|
132
|
-
// if (process.platform === 'win32') {
|
|
133
|
-
// return show.windowsWarning();
|
|
134
|
-
// }
|
|
135
134
|
// process cli args
|
|
136
135
|
let args = await getUserArgs();
|
|
137
136
|
// If no args, prompt user
|
|
@@ -139,6 +138,10 @@ async function promptAndGetConfig() {
|
|
|
139
138
|
show.welcome();
|
|
140
139
|
args = await getUserAnswers();
|
|
141
140
|
}
|
|
141
|
+
if (args.error) {
|
|
142
|
+
(0, tracking_1.trackUsage)('none', false, 'none');
|
|
143
|
+
return args.error();
|
|
144
|
+
}
|
|
142
145
|
// Homogenizing terminal args with prompt args
|
|
143
146
|
args.contract = args.contract || 'none';
|
|
144
147
|
args.frontend = args.frontend || 'none';
|