create-near-app 3.1.0 → 4.0.0-beta.3.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.
Files changed (92) hide show
  1. package/README.md +37 -31
  2. package/dist/app.js +76 -0
  3. package/dist/checks.js +34 -0
  4. package/dist/make.js +137 -0
  5. package/dist/messages.js +56 -0
  6. package/dist/package-json.js +164 -0
  7. package/dist/tracking.js +34 -0
  8. package/dist/types.js +3 -0
  9. package/dist/user-input.js +211 -0
  10. package/index.js +1 -233
  11. package/package.json +49 -40
  12. package/{contracts → templates/contracts}/assemblyscript/README.md +6 -5
  13. package/templates/contracts/assemblyscript/as-pect.config.js +1 -0
  14. package/{contracts → templates/contracts}/assemblyscript/asconfig.json +0 -0
  15. package/{contracts → templates/contracts}/assemblyscript/assembly/__tests__/as-pect.d.ts +0 -0
  16. package/templates/contracts/assemblyscript/assembly/__tests__/main.spec.ts +11 -0
  17. package/{contracts → templates/contracts}/assemblyscript/assembly/as_types.d.ts +0 -0
  18. package/{contracts → templates/contracts}/assemblyscript/assembly/index.ts +5 -5
  19. package/{contracts → templates/contracts}/assemblyscript/assembly/tsconfig.json +0 -0
  20. package/templates/contracts/assemblyscript/package.json +14 -0
  21. package/templates/contracts/js/README.md +23 -0
  22. package/templates/contracts/js/babel.config.json +7 -0
  23. package/templates/contracts/js/package.json +18 -0
  24. package/templates/contracts/js/src/contract.ts +31 -0
  25. package/templates/contracts/js/tsconfig.json +10 -0
  26. package/{contracts → templates/contracts}/rust/.cargo/config +0 -0
  27. package/{contracts → templates/contracts}/rust/Cargo.toml +1 -1
  28. package/{contracts → templates/contracts}/rust/README.md +6 -8
  29. package/{contracts → templates/contracts}/rust/src/lib.rs +0 -0
  30. package/templates/frontend/react/frontend/App.js +66 -0
  31. package/templates/{react/frontend/assets/img → frontend/react/frontend/assets}/favicon.ico +0 -0
  32. package/templates/{vanilla/frontend/assets/css → frontend/react/frontend/assets}/global.css +64 -80
  33. package/templates/{react/frontend/assets/img → frontend/react/frontend/assets}/logo-black.svg +0 -0
  34. package/templates/{react/frontend/assets/img → frontend/react/frontend/assets}/logo-white.svg +0 -0
  35. package/templates/frontend/react/frontend/index.html +15 -0
  36. package/templates/frontend/react/frontend/index.js +15 -0
  37. package/templates/{react/frontend/assets/js/near/utils.js → frontend/react/frontend/near-api.js} +19 -19
  38. package/templates/frontend/react/frontend/near-config.js +61 -0
  39. package/templates/frontend/react/frontend/package.json +44 -0
  40. package/templates/frontend/react/frontend/ui-components.js +60 -0
  41. package/templates/{vanilla/frontend/assets/img → frontend/vanilla/frontend/assets}/favicon.ico +0 -0
  42. package/templates/{react/frontend/assets/css → frontend/vanilla/frontend/assets}/global.css +64 -80
  43. package/templates/{vanilla/frontend/assets/img → frontend/vanilla/frontend/assets}/logo-black.svg +0 -0
  44. package/templates/{vanilla/frontend/assets/img → frontend/vanilla/frontend/assets}/logo-white.svg +0 -0
  45. package/templates/frontend/vanilla/frontend/index.html +86 -0
  46. package/templates/frontend/vanilla/frontend/index.js +78 -0
  47. package/templates/{vanilla/frontend/assets/js/near/utils.js → frontend/vanilla/frontend/near-api.js} +18 -18
  48. package/templates/frontend/vanilla/frontend/near-config.js +62 -0
  49. package/templates/frontend/vanilla/frontend/package.json +18 -0
  50. package/templates/integration-tests/overrides/js-contract/js-tests/src/main.ava.ts +46 -0
  51. package/templates/integration-tests/overrides/js-contract/rust-tests/src/tests.rs +74 -0
  52. package/{integration-tests/js → templates/integration-tests/shared/js-tests}/ava.config.cjs +9 -9
  53. package/{integration-tests/js → templates/integration-tests/shared/js-tests}/package.json +5 -4
  54. package/templates/integration-tests/shared/js-tests/src/main.ava.ts +44 -0
  55. package/{integration-tests/rs → templates/integration-tests/shared/rust-tests}/Cargo.toml +1 -1
  56. package/{integration-tests/rs → templates/integration-tests/shared/rust-tests}/src/tests.rs +7 -5
  57. package/templates/{none → shared}/.gitpod.yml +2 -2
  58. package/templates/{vanilla → shared}/README.md +29 -30
  59. package/templates/{react → shared}/near.gitignore +1 -1
  60. package/contracts/assemblyscript/as-pect.config.js +0 -1
  61. package/contracts/assemblyscript/assembly/__tests__/main.spec.ts +0 -11
  62. package/contracts/assemblyscript/package.json +0 -13
  63. package/integration-tests/js/src/config.ts +0 -31
  64. package/integration-tests/js/src/main.ava.ts +0 -32
  65. package/integration-tests/ts/ava.config.cjs +0 -9
  66. package/integration-tests/ts/package.json +0 -16
  67. package/integration-tests/ts/src/main.ava.ts +0 -44
  68. package/templates/none/.gitattributes +0 -2
  69. package/templates/none/README.md +0 -101
  70. package/templates/none/near.gitignore +0 -27
  71. package/templates/none/neardev/shared-test/test.near.json +0 -1
  72. package/templates/none/package.json +0 -33
  73. package/templates/react/.gitpod.yml +0 -6
  74. package/templates/react/README.md +0 -102
  75. package/templates/react/ava.config.cjs +0 -9
  76. package/templates/react/frontend/App.js +0 -202
  77. package/templates/react/frontend/__mocks__/fileMock.js +0 -3
  78. package/templates/react/frontend/assets/js/near/config.js +0 -63
  79. package/templates/react/frontend/index.html +0 -25
  80. package/templates/react/frontend/index.js +0 -14
  81. package/templates/react/neardev/shared-test/test.near.json +0 -1
  82. package/templates/react/package.json +0 -55
  83. package/templates/vanilla/.gitattributes +0 -2
  84. package/templates/vanilla/.gitpod.yml +0 -6
  85. package/templates/vanilla/frontend/assets/js/index.js +0 -74
  86. package/templates/vanilla/frontend/assets/js/near/config.js +0 -63
  87. package/templates/vanilla/frontend/index.html +0 -103
  88. package/templates/vanilla/near.gitignore +0 -27
  89. package/templates/vanilla/neardev/shared-test/test.near.json +0 -1
  90. package/templates/vanilla/package.json +0 -34
  91. package/utils/rust-setup.js +0 -113
  92. package/utils/tracking.js +0 -29
@@ -1,34 +0,0 @@
1
- {
2
- "name": "greeter",
3
- "version": "1.0.0",
4
- "license": "(MIT AND Apache-2.0)",
5
- "scripts": {
6
- "build": "npm run build:contract && npm run build:web",
7
- "build:contract": "cd contract && npm run build && cp ./build/release/greeter.wasm ../out/main.wasm",
8
- "build:web": "parcel build frontend/index.html --public-url ./",
9
- "deploy": "npm run build:contract && near dev-deploy",
10
- "start": "npm run deploy && echo The app is starting! && env-cmd -f ./neardev/dev-account.env parcel frontend/index.html --open",
11
- "dev": "nodemon --watch contract -e ts --exec \"npm run start\"",
12
- "test": "npm run build:contract && npm run test:unit && npm run test:integration",
13
- "test:unit": "cd contract && npm i && npm run test",
14
- "test:integration": "npm run test:integration:ts && npm run test:integration:rs",
15
- "test:integration:ts": "cd integration-tests/ts && npm run test",
16
- "test:integration:rs": "cd integration-tests/rs && cargo run --example integration-tests"
17
- },
18
- "devDependencies": {
19
- "env-cmd": "^10.1.0",
20
- "near-cli": "^3.3.0",
21
- "nodemon": "~2.0.16",
22
- "parcel": "^2.6.0",
23
- "ava": "^4.2.0",
24
- "near-workspaces": "^2.0.0",
25
- "typescript": "^4.7.2",
26
- "process": "^0.11.10",
27
- "ts-node": "^10.8.0"
28
- },
29
- "dependencies": {
30
- "near-api-js": "^0.44.2",
31
- "near-sdk-as": "^3.2.3",
32
- "regenerator-runtime": "~0.13.9"
33
- }
34
- }
@@ -1,113 +0,0 @@
1
- const chalk = require('chalk')
2
- const os = require('os')
3
- const readline = require('readline')
4
- const sh = require('shelljs')
5
-
6
- // script from https://rustup.rs/ with auto-accept flag "-y"
7
- const installRustupScript = 'curl --proto \'=https\' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y'
8
- const updatePath = '. $HOME/.cargo/env'
9
- const addWasm32TargetScript = 'rustup target add wasm32-unknown-unknown'
10
- // We should update PATH in the same script because every new Bash scripts are executed in a separate shell
11
- const updatePathAndAddWasm32TargetScript = updatePath + ' && ' + addWasm32TargetScript
12
-
13
- const isWindows = os.platform() === 'win32'
14
-
15
- function isRustupInstalled() {
16
- console.log(chalk`Checking if {bold rustup} is installed...`)
17
- const isInstalled = sh.exec('rustup --version').code === 0
18
- console.log(chalk`{bold rustup} is`, isInstalled ? 'installed\n' : 'not installed\n')
19
- return isInstalled
20
- }
21
-
22
- function isWasmTargetAdded() {
23
- console.log(chalk`Checking installed {bold Rust targets}..`)
24
- const addedTargets = sh.exec('rustup target list --installed').stdout
25
- const isWasmTargetAdded = addedTargets.includes('wasm32-unknown-unknown')
26
- console.log(chalk`{bold wasm32-unknown-unknown} target `, isWasmTargetAdded ? 'already added' : 'is not added')
27
- return isWasmTargetAdded
28
- }
29
-
30
- function installRustup() {
31
- console.log(chalk`Installing {bold rustup}...`)
32
- sh.exec(installRustupScript)
33
- }
34
-
35
- function addWasm32Target() {
36
- console.log(chalk`Adding {bold wasm32-unknown-unknown} target...`)
37
- sh.exec(updatePathAndAddWasm32TargetScript)
38
- }
39
-
40
- async function askYesNoQuestionAndRunFunction(question, functionToRun = null) {
41
- const rl = readline.createInterface({
42
- input: process.stdin,
43
- output: process.stdout,
44
- })
45
- try {
46
- for (let attempt = 0; attempt < 4; attempt++) {
47
- const answer = await new Promise((resolve) => {
48
- rl.question(question, (userInput) => {
49
- if (['y', 'Y', ''].includes(userInput)) {
50
- if (functionToRun) functionToRun()
51
- resolve(true)
52
- }
53
- if (userInput === 'n') {
54
- resolve(false)
55
- }
56
- resolve(undefined)
57
- })
58
- })
59
- if (answer !== undefined) {
60
- return answer
61
- }
62
- }
63
- } finally {
64
- rl.close()
65
- }
66
- return false
67
- }
68
-
69
- const installRustupDisclaimer = chalk`In order to work with {bold rust} smart contracts we recommend you install {bold rustup}, the Rust toolchain installer.`
70
- const addWasm32TargetDisclaimer = chalk`To build Rust smart contracts you need to add {bold WebAssembly} compiler target to Rust toolchain.`
71
-
72
- const installRustupQuestion = chalk`
73
- ${installRustupDisclaimer} We can run the following command to do it for you:
74
- {bold ${installRustupScript}}
75
- Continue with installation (Y/n)?: `
76
-
77
- const addWasm32TargetQuestion = chalk`
78
- ${addWasm32TargetDisclaimer} We can run the following command to do it for you:
79
- {bold ${addWasm32TargetScript}}
80
- Continue with installation (Y/n)?: `
81
-
82
- const rustupAndWasm32WindowsInstallationInstructions = chalk`
83
- ${installRustupDisclaimer}
84
- 1. Go to https://rustup.rs
85
- 2. Download {bold rustup-init.exe}
86
- 3. Install it on your system
87
- ${addWasm32TargetDisclaimer}
88
- Run the following command to do it:
89
- {bold ${addWasm32TargetScript}}
90
- Press {bold Enter} to continue project creation.`
91
-
92
- async function setupRustAndWasm32Target() {
93
- try {
94
- if (isWindows) {
95
- await askYesNoQuestionAndRunFunction(rustupAndWasm32WindowsInstallationInstructions)
96
- return false
97
- }
98
- let wasRustupInstalled = false
99
- if (!isRustupInstalled()) {
100
- wasRustupInstalled = await askYesNoQuestionAndRunFunction(installRustupQuestion, installRustup)
101
- }
102
- if (!isWasmTargetAdded()) {
103
- await askYesNoQuestionAndRunFunction(addWasm32TargetQuestion, addWasm32Target)
104
- }
105
- return wasRustupInstalled
106
- } catch (e) {
107
- console.log(chalk`Failed to run {bold rust} setup script`, e)
108
- }
109
- }
110
-
111
- module.exports = {
112
- setupRustAndWasm32Target,
113
- }
package/utils/tracking.js DELETED
@@ -1,29 +0,0 @@
1
- const MIXPANEL_TOKEN = 'df164f13212cbb0dfdae991da60e87f2'
2
-
3
- const chalk = require('chalk')
4
- const mixpanel = require('mixpanel').init(MIXPANEL_TOKEN)
5
-
6
- const track = async (frontendType, contractType) => {
7
- // prevents logging from CI
8
- if (process.env.IS_GITHUB_ACTION) {
9
- console.log('Mixpanel logging is skipped in CI env')
10
- return
11
- }
12
- try {
13
- console.log(chalk`NEAR collects anonymous information on the commands used. No personal information that could identify you will be shared.\n`)
14
- const mixPanelProperties = {
15
- frontend: frontendType,
16
- contract: contractType,
17
- os: process.platform,
18
- timestamp: new Date().toString()
19
- }
20
- mixpanel.track('track create near app', mixPanelProperties)
21
- } catch (e) {
22
- console.error(
23
- 'Warning: problem while sending tracking data. Error: ',
24
- e
25
- )
26
- }
27
- }
28
-
29
- exports.track = track