create-near-app 4.1.0 → 5.0.0-rc.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/dist/messages.js +2 -2
- package/dist/package-json.js +27 -86
- package/dist/types.js +1 -1
- package/dist/user-input.js +0 -1
- package/package.json +1 -1
- package/templates/frontend/react/ui-components.js +3 -3
- package/templates/frontend/vanilla/index.html +5 -7
- package/templates/contracts/assemblyscript/README.md +0 -26
- package/templates/contracts/assemblyscript/as-pect.config.js +0 -1
- package/templates/contracts/assemblyscript/asconfig.json +0 -3
- package/templates/contracts/assemblyscript/assembly/__tests__/as-pect.d.ts +0 -1
- package/templates/contracts/assemblyscript/assembly/__tests__/main.spec.ts +0 -11
- package/templates/contracts/assemblyscript/assembly/as_types.d.ts +0 -1
- package/templates/contracts/assemblyscript/assembly/index.ts +0 -23
- package/templates/contracts/assemblyscript/assembly/tsconfig.json +0 -6
- package/templates/contracts/assemblyscript/package.json +0 -14
package/dist/messages.js
CHANGED
|
@@ -24,7 +24,7 @@ Please refer to https://github.com/near/create-near-app README to troubleshoot.
|
|
|
24
24
|
Notice: some platforms aren't supported (yet).
|
|
25
25
|
{bold {red ==========================================}}`);
|
|
26
26
|
exports.setupFailed = setupFailed;
|
|
27
|
-
const successContractToText = (contract) => (0, chalk_1.default) `with a smart contract in {bold ${contract === 'rust' ? 'Rust' :
|
|
27
|
+
const successContractToText = (contract) => (0, chalk_1.default) `with a smart contract in {bold ${contract === 'rust' ? 'Rust' : 'JavaScript'}}`;
|
|
28
28
|
exports.successContractToText = successContractToText;
|
|
29
29
|
const successFrontendToText = (frontend) => frontend === 'none' ? '' : (0, chalk_1.default) ` and a frontend template${frontend === 'react' ? (0, chalk_1.default) `{bold in React.js}` : ''}`;
|
|
30
30
|
exports.successFrontendToText = successFrontendToText;
|
|
@@ -48,7 +48,7 @@ ${contract === 'rust' ? (0, chalk_1.default) `🦀 If you are new to Rust please
|
|
|
48
48
|
exports.setupSuccess = setupSuccess;
|
|
49
49
|
const argsError = () => (0, exports.show)((0, chalk_1.default) `{red Arguments error}
|
|
50
50
|
Run {blue npx create-near-app} without arguments, or use:
|
|
51
|
-
npx create-near-app <projectName> --contract rust|js
|
|
51
|
+
npx create-near-app <projectName> --contract rust|js --frontend react|vanilla|none --tests js|rust`);
|
|
52
52
|
exports.argsError = argsError;
|
|
53
53
|
const unsupportedNodeVersion = (supported) => (0, exports.show)((0, chalk_1.default) `{red We support node.js version ${supported} or later}`);
|
|
54
54
|
exports.unsupportedNodeVersion = unsupportedNodeVersion;
|
package/dist/package-json.js
CHANGED
|
@@ -41,10 +41,6 @@ const buildScript = (hasFrontend) => hasFrontend ? {
|
|
|
41
41
|
};
|
|
42
42
|
const buildContractScript = (contract) => {
|
|
43
43
|
switch (contract) {
|
|
44
|
-
case 'assemblyscript':
|
|
45
|
-
return {
|
|
46
|
-
'build:contract': 'cd contract && npm run build',
|
|
47
|
-
};
|
|
48
44
|
case 'js':
|
|
49
45
|
return {
|
|
50
46
|
'build:contract': 'cd contract && npm run build',
|
|
@@ -57,7 +53,6 @@ const buildContractScript = (contract) => {
|
|
|
57
53
|
};
|
|
58
54
|
const deployScript = (contract) => {
|
|
59
55
|
switch (contract) {
|
|
60
|
-
case 'assemblyscript':
|
|
61
56
|
case 'js':
|
|
62
57
|
return {
|
|
63
58
|
'deploy': 'cd contract && npm run deploy',
|
|
@@ -71,102 +66,48 @@ const deployScript = (contract) => {
|
|
|
71
66
|
const unitTestScripts = (contract) => {
|
|
72
67
|
switch (contract) {
|
|
73
68
|
case 'js':
|
|
74
|
-
case 'assemblyscript':
|
|
75
69
|
return { 'test:unit': 'cd contract && npm test' };
|
|
76
70
|
case 'rust':
|
|
77
71
|
return { 'test:unit': 'cd contract && cargo test' };
|
|
78
72
|
}
|
|
79
73
|
};
|
|
80
74
|
const integrationTestScripts = (contract, tests) => {
|
|
75
|
+
let wasm_path = '';
|
|
81
76
|
switch (contract) {
|
|
82
|
-
case 'assemblyscript':
|
|
83
|
-
if (tests === 'js') {
|
|
84
|
-
return {
|
|
85
|
-
'test:integration': 'npm run build:contract && cd integration-tests && npm test -- -- "./contract/build/release/hello_near.wasm"',
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
return {
|
|
90
|
-
'test:integration': 'npm run build:contract && cd integration-tests && cargo run --example integration-tests "../contract/build/release/hello_near.wasm"',
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
77
|
case 'js':
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
78
|
+
wasm_path = 'contract/build/hello_near.wasm';
|
|
79
|
+
break;
|
|
80
|
+
case 'rust':
|
|
81
|
+
wasm_path = 'contract/target/wasm32-unknown-unknown/release/hello_near.wasm';
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
let run_test = '';
|
|
85
|
+
switch (tests) {
|
|
86
|
+
case 'js':
|
|
87
|
+
run_test = `npm test -- -- "./${wasm_path}"`;
|
|
88
|
+
break;
|
|
104
89
|
case 'rust':
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
'test:integration': 'npm run build:contract && cd integration-tests && npm test -- -- "./contract/target/wasm32-unknown-unknown/release/hello_near.wasm"',
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return {
|
|
112
|
-
'test:integration': 'npm run build:contract && cd integration-tests && cargo run --example integration-tests "../contract/target/wasm32-unknown-unknown/release/hello_near.wasm"',
|
|
113
|
-
};
|
|
114
|
-
}
|
|
90
|
+
run_test = `cargo run --example integration-tests "../${wasm_path}"`;
|
|
91
|
+
break;
|
|
115
92
|
}
|
|
93
|
+
return {
|
|
94
|
+
'test:integration': `cd integration-tests && ${run_test}`,
|
|
95
|
+
};
|
|
116
96
|
};
|
|
117
97
|
const npmInstallScript = (contract, hasFrontend, tests) => {
|
|
98
|
+
const frontend_install = hasFrontend ? 'cd frontend && npm install && cd ..' : 'echo no frontend';
|
|
99
|
+
const test_install = (tests === 'js') ? 'cd integration-tests && npm install && cd ..' : 'echo rs tests';
|
|
100
|
+
let contract_install = '';
|
|
118
101
|
switch (contract) {
|
|
119
|
-
case 'assemblyscript':
|
|
120
|
-
if (hasFrontend) {
|
|
121
|
-
if (tests === 'js') {
|
|
122
|
-
return { 'postinstall': 'cd contract && npm install --ignore-scripts && cd ../integration-tests && npm install && cd ../frontend && npm install && cd ..' };
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
return { 'postinstall': 'cd contract && npm install --ignore-scripts && cd ../frontend && npm install && cd ..' };
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
if (tests === 'js') {
|
|
130
|
-
return { 'postinstall': 'cd contract && npm install --ignore-scripts && cd ../integration-tests && npm install && cd ..' };
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
return { 'postinstall': 'cd contract && npm install --ignore-scripts && cd ..' };
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
102
|
case 'js':
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return { 'postinstall': 'cd contract && npm install && cd ../integration-tests && npm install && cd ../frontend && npm install && cd ..' };
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
return { 'postinstall': 'cd contract && npm install && cd ../frontend && npm install && cd ..' };
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
if (tests === 'js') {
|
|
147
|
-
return { 'postinstall': 'cd contract && npm install && cd ../integration-tests && npm install && cd ..' };
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
return { 'postinstall': 'cd contract && npm install && cd ..' };
|
|
151
|
-
}
|
|
152
|
-
}
|
|
103
|
+
contract_install = 'cd contract && npm install';
|
|
104
|
+
break;
|
|
153
105
|
case 'rust':
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return { 'postinstall': 'cd frontend && npm install && cd ../integration-tests && npm install && cd ..' };
|
|
157
|
-
}
|
|
158
|
-
else {
|
|
159
|
-
return { 'postinstall': 'cd frontend && npm install && cd ..' };
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
if (tests === 'js') {
|
|
164
|
-
return { 'postinstall': 'cd ./integration-tests && npm install && cd ..' };
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
return {};
|
|
168
|
-
}
|
|
169
|
-
}
|
|
106
|
+
contract_install = 'echo rs contract';
|
|
107
|
+
break;
|
|
170
108
|
}
|
|
109
|
+
return {
|
|
110
|
+
'postinstall': `${frontend_install} && ${test_install} && ${contract_install}`
|
|
111
|
+
};
|
|
171
112
|
};
|
|
172
113
|
//# sourceMappingURL=package-json.js.map
|
package/dist/types.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TESTING_FRAMEWORKS = exports.FRONTENDS = exports.CONTRACTS = void 0;
|
|
4
|
-
exports.CONTRACTS = ['
|
|
4
|
+
exports.CONTRACTS = ['js', 'rust'];
|
|
5
5
|
exports.FRONTENDS = ['react', 'vanilla', 'none'];
|
|
6
6
|
exports.TESTING_FRAMEWORKS = ['rust', 'js'];
|
|
7
7
|
//# sourceMappingURL=types.js.map
|
package/dist/user-input.js
CHANGED
|
@@ -77,7 +77,6 @@ exports.validateUserArgs = validateUserArgs;
|
|
|
77
77
|
const contractChoices = [
|
|
78
78
|
{ title: 'TypeScript', value: 'js' },
|
|
79
79
|
{ title: 'Rust', value: 'rust' },
|
|
80
|
-
{ title: 'AssemblyScript', value: 'assemblyscript' },
|
|
81
80
|
];
|
|
82
81
|
const testsChoices = [
|
|
83
82
|
{ title: 'Rust Sandbox Tests', value: 'rust' },
|
package/package.json
CHANGED
|
@@ -43,12 +43,12 @@ export function EducationalText() {
|
|
|
43
43
|
</p>
|
|
44
44
|
<ol>
|
|
45
45
|
<li>
|
|
46
|
-
Look in <code>src/App.js</code>
|
|
46
|
+
Look in <code>src/App.js</code> - you'll see <code>getGreeting</code> and <code>setGreeting</code> being called on <code>contract</code>. What's this?
|
|
47
47
|
</li>
|
|
48
48
|
<li>
|
|
49
|
-
Ultimately, this <code>contract</code> code is defined in <code
|
|
49
|
+
Ultimately, this <code>contract</code> code is defined in <code>./contract</code> – this is the source code for your <a target="_blank" rel="noreferrer" href="https://docs.near.org/docs/develop/contracts/overview">smart contract</a>.</li>
|
|
50
50
|
<li>
|
|
51
|
-
When you run <code>npm run
|
|
51
|
+
When you run <code>npm run deploy</code>, the code in <code>./contract</code> gets deployed to the NEAR testnet. You can see how this happens by looking in <code>package.json</code>.</li>
|
|
52
52
|
</ol>
|
|
53
53
|
<hr />
|
|
54
54
|
<p>
|
|
@@ -60,20 +60,18 @@
|
|
|
60
60
|
</p>
|
|
61
61
|
<ol>
|
|
62
62
|
<li>
|
|
63
|
-
Look in <code
|
|
64
|
-
and <code>
|
|
63
|
+
Look in <code>./frontend/index.js</code> – you'll see <code>getGreeting</code>
|
|
64
|
+
and <code>setGreeting</code> being called on <code>contract</code>.
|
|
65
65
|
What's this?
|
|
66
66
|
</li>
|
|
67
67
|
<li>
|
|
68
68
|
Ultimately, this <code>contract</code> code is defined in
|
|
69
|
-
<code
|
|
69
|
+
<code>./contract</code> – this is the source code for your
|
|
70
70
|
<a target="_blank" href="https://docs.near.org/docs/develop/contracts/overview">smart contract</a>.
|
|
71
71
|
</li>
|
|
72
72
|
<li>
|
|
73
|
-
When you run <code>npm run dev</code>, the code
|
|
74
|
-
|
|
75
|
-
can see how this happens by looking in <code>package.json</code> at the
|
|
76
|
-
<code>scripts</code> section to find the <code>dev</code> command.
|
|
73
|
+
When you run <code>npm run dev</code>, the contract's code gets deployed
|
|
74
|
+
to the NEAR testnet. You can see how this happens by looking in <code>package.json</code>.
|
|
77
75
|
</li>
|
|
78
76
|
</ol>
|
|
79
77
|
<hr>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
Hello NEAR!
|
|
2
|
-
===========
|
|
3
|
-
|
|
4
|
-
A [smart contract] written in [AssemblyScript] for an app initialized with [create-near-app]
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Quick Start
|
|
8
|
-
===========
|
|
9
|
-
|
|
10
|
-
Before you compile this code, you will need to install [Node.js] ≥ 16
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Exploring The Code
|
|
14
|
-
==================
|
|
15
|
-
|
|
16
|
-
1. The main smart contract code lives in `assembly/index.ts`.
|
|
17
|
-
2. There are two functions to the smart contract: `get_greeting` and `set_greeting`.
|
|
18
|
-
3. Tests: You can run smart contract tests with the `npm run test` script. This runs
|
|
19
|
-
standard AssemblyScript tests using [as-pect].
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
[smart contract]: https://docs.near.org/develop/welcome
|
|
23
|
-
[AssemblyScript]: https://www.assemblyscript.org/
|
|
24
|
-
[create-near-app]: https://github.com/near/create-near-app
|
|
25
|
-
[Node.js]: https://nodejs.org/en/download/package-manager/
|
|
26
|
-
[as-pect]: https://www.npmjs.com/package/@as-pect/cli
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = require('near-sdk-as/imports');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="@as-pect/assembly/types/as-pect" />
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { set_greeting, get_greeting } from '..';
|
|
2
|
-
|
|
3
|
-
describe('Greeting ', () => {
|
|
4
|
-
it('should get the default greeting', () => {
|
|
5
|
-
expect(get_greeting()).toBe('Hello');
|
|
6
|
-
});
|
|
7
|
-
it('should change the greeting', () => {
|
|
8
|
-
set_greeting('howdy');
|
|
9
|
-
expect(get_greeting()).toBe('howdy');
|
|
10
|
-
});
|
|
11
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/// <reference types="near-sdk-as/assembly/as_types" />
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Example smart contract written in AssemblyScript
|
|
3
|
-
*
|
|
4
|
-
* Learn more about writing NEAR smart contracts with AssemblyScript:
|
|
5
|
-
* https://near-docs.io/develop/welcome
|
|
6
|
-
*
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { logging, storage } from 'near-sdk-as';
|
|
10
|
-
|
|
11
|
-
const DEFAULT_MESSAGE = 'Hello';
|
|
12
|
-
|
|
13
|
-
// Public method - returns the greeting saved, defaulting to DEFAULT_MESSAGE
|
|
14
|
-
export function get_greeting(): string {
|
|
15
|
-
return storage.getPrimitive<string>('message', DEFAULT_MESSAGE);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Public method - accepts a greeting, such as 'howdy', and records it
|
|
19
|
-
export function set_greeting(message: string): void {
|
|
20
|
-
// Use logging.log to record logs permanently to the blockchain!
|
|
21
|
-
logging.log(`Saving greeting '${message}'`);
|
|
22
|
-
storage.set<string>('message', message);
|
|
23
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hello_near",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"license": "(MIT AND Apache-2.0)",
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "asb",
|
|
7
|
-
"deploy": "npm run build && rm -rf neardev && near dev-deploy --wasmFile ./build/release/hello_near.wasm",
|
|
8
|
-
"test": "asp --nologo"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"near-cli": "^3.3.0",
|
|
12
|
-
"near-sdk-as": "^3.2.3"
|
|
13
|
-
}
|
|
14
|
-
}
|