create-near-app 6.0.0-beta.2 → 6.0.0-beta.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 +6 -11
- package/dist/make.js +44 -81
- package/dist/messages.js +31 -23
- package/dist/package-json.js +16 -16
- package/dist/tracking.js +1 -1
- package/dist/types.js +5 -4
- package/dist/user-input.js +81 -89
- package/package.json +1 -1
- package/templates/contracts/{rust → rs}/Cargo.toml +0 -3
- package/templates/contracts/{rust → rs}/README.md +14 -5
- package/templates/contracts/rs/build.sh +3 -0
- package/templates/contracts/rs/deploy.sh +2 -0
- package/templates/contracts/{rust → rs}/src/lib.rs +4 -6
- package/templates/contracts/rs/test-rs.sh +9 -0
- package/templates/contracts/rs/test-ts.sh +10 -0
- package/templates/contracts/{js → ts}/README.md +1 -0
- package/templates/contracts/ts/package.json +20 -0
- package/templates/frontend/next/.eslintrc.json +3 -0
- package/templates/frontend/next/README.md +36 -0
- package/templates/frontend/next/jsconfig.json +7 -0
- package/templates/frontend/next/next.config.js +6 -0
- package/templates/frontend/next/package.json +40 -0
- package/templates/frontend/next/public/near-logo.svg +43 -0
- package/templates/frontend/next/public/near.svg +1 -0
- package/templates/frontend/next/src/app/app.module.css +228 -0
- package/templates/frontend/next/src/app/globals.css +95 -0
- package/templates/frontend/next/src/app/hello-components/page.js +44 -0
- package/templates/frontend/next/src/app/hello-near/page.js +64 -0
- package/templates/frontend/next/src/app/layout.js +22 -0
- package/templates/frontend/next/src/app/page.js +37 -0
- package/templates/frontend/next/src/components/cards.js +46 -0
- package/templates/frontend/next/src/components/navigation.js +36 -0
- package/templates/frontend/next/src/components/vm-component.js +26 -0
- package/templates/frontend/next/src/config.js +21 -0
- package/templates/frontend/next/src/wallets/wallet-selector.js +128 -0
- package/templates/frontend/{gateway/src/data/web3.ts → next/src/wallets/web3-wallet.ts} +4 -7
- package/templates/frontend/vanilla/.babelrc +7 -0
- package/templates/frontend/vanilla/package.json +27 -13
- package/templates/frontend/vanilla/{assets → src/assets}/global.css +25 -56
- package/templates/frontend/vanilla/src/components.html +61 -0
- package/templates/frontend/vanilla/src/components.js +63 -0
- package/templates/frontend/vanilla/src/hello-near.html +80 -0
- package/templates/frontend/vanilla/src/hello.js +61 -0
- package/templates/frontend/vanilla/src/index.html +65 -0
- package/templates/frontend/vanilla/{near-wallet.js → src/near-wallet.js} +20 -18
- package/templates/frontend/vanilla/webpack.config.js +79 -0
- package/templates/{integration-tests/rust-tests → sandbox-tests/sandbox-rs}/Cargo.toml +5 -5
- package/templates/{integration-tests/js-tests → sandbox-tests/sandbox-ts}/package.json +6 -6
- package/templates/contracts/js/build.sh +0 -5
- package/templates/contracts/js/deploy.sh +0 -18
- package/templates/contracts/js/package.json +0 -19
- package/templates/contracts/rust/build.sh +0 -6
- package/templates/contracts/rust/deploy.sh +0 -18
- package/templates/frontend/gateway/.env +0 -1
- package/templates/frontend/gateway/.nvmrc +0 -1
- package/templates/frontend/gateway/.prettierrc +0 -6
- package/templates/frontend/gateway/next.config.js +0 -15
- package/templates/frontend/gateway/package.json +0 -74
- package/templates/frontend/gateway/public/apple-touch-icon.png +0 -0
- package/templates/frontend/gateway/public/bos-meta.png +0 -0
- package/templates/frontend/gateway/public/favicon.png +0 -0
- package/templates/frontend/gateway/public/fonts/FKGrotesk.woff2 +0 -0
- package/templates/frontend/gateway/public/fonts/Mona-Sans.woff2 +0 -0
- package/templates/frontend/gateway/public/logo192.png +0 -0
- package/templates/frontend/gateway/public/robots.txt +0 -3
- package/templates/frontend/gateway/public/site.webmanifest +0 -8
- package/templates/frontend/gateway/src/assets/images/near-icon.svg +0 -3
- package/templates/frontend/gateway/src/components/MetaTags.tsx +0 -22
- package/templates/frontend/gateway/src/components/component/ComponentWrapperPage.tsx +0 -27
- package/templates/frontend/gateway/src/components/layouts/DefaultLayout.tsx +0 -16
- package/templates/frontend/gateway/src/components/layouts/SimpleLayout.tsx +0 -9
- package/templates/frontend/gateway/src/components/lib/Button/Button.tsx +0 -379
- package/templates/frontend/gateway/src/components/lib/Button/index.tsx +0 -1
- package/templates/frontend/gateway/src/components/lib/Spinner/Spinner.tsx +0 -33
- package/templates/frontend/gateway/src/components/lib/Spinner/index.ts +0 -1
- package/templates/frontend/gateway/src/components/lib/Text/Text.tsx +0 -14
- package/templates/frontend/gateway/src/components/lib/Text/index.tsx +0 -1
- package/templates/frontend/gateway/src/components/lib/Toast/README.md +0 -83
- package/templates/frontend/gateway/src/components/lib/Toast/Toast.tsx +0 -25
- package/templates/frontend/gateway/src/components/lib/Toast/Toaster.tsx +0 -48
- package/templates/frontend/gateway/src/components/lib/Toast/api.ts +0 -6
- package/templates/frontend/gateway/src/components/lib/Toast/index.ts +0 -3
- package/templates/frontend/gateway/src/components/lib/Toast/store.ts +0 -83
- package/templates/frontend/gateway/src/components/lib/Toast/styles.ts +0 -126
- package/templates/frontend/gateway/src/components/navigation/Navigation.tsx +0 -23
- package/templates/frontend/gateway/src/components/navigation/UserDropdownMenu.tsx +0 -209
- package/templates/frontend/gateway/src/components/navigation/desktop/DesktopNavigation.tsx +0 -109
- package/templates/frontend/gateway/src/components/navigation/desktop/MainNavigationMenu.tsx +0 -170
- package/templates/frontend/gateway/src/components/navigation/icons/close.svg +0 -22
- package/templates/frontend/gateway/src/components/navigation/icons/near-icon.svg +0 -3
- package/templates/frontend/gateway/src/components/navigation/icons/near-logo.svg +0 -14
- package/templates/frontend/gateway/src/components/navigation/icons/return.svg +0 -29
- package/templates/frontend/gateway/src/components/navigation/icons/search.svg +0 -3
- package/templates/frontend/gateway/src/components/navigation/mobile/AccordionMenu.tsx +0 -141
- package/templates/frontend/gateway/src/components/navigation/mobile/Menu.tsx +0 -86
- package/templates/frontend/gateway/src/components/navigation/mobile/MobileNavigation.tsx +0 -131
- package/templates/frontend/gateway/src/components/navigation/navigation-categories.ts +0 -75
- package/templates/frontend/gateway/src/components/vm/VmCommitButton.tsx +0 -20
- package/templates/frontend/gateway/src/components/vm/VmComponent.tsx +0 -29
- package/templates/frontend/gateway/src/components/vm/VmInitializer.tsx +0 -124
- package/templates/frontend/gateway/src/data/components.ts +0 -50
- package/templates/frontend/gateway/src/hooks/useBosComponents.ts +0 -14
- package/templates/frontend/gateway/src/hooks/useBosLoaderInitializer.ts +0 -60
- package/templates/frontend/gateway/src/hooks/useFlags.ts +0 -40
- package/templates/frontend/gateway/src/hooks/useLayout.tsx +0 -12
- package/templates/frontend/gateway/src/index.d.ts +0 -9
- package/templates/frontend/gateway/src/pages/_app.tsx +0 -47
- package/templates/frontend/gateway/src/pages/_document.tsx +0 -27
- package/templates/frontend/gateway/src/pages/dig.tsx +0 -25
- package/templates/frontend/gateway/src/pages/flags.tsx +0 -83
- package/templates/frontend/gateway/src/pages/hello-api.tsx +0 -105
- package/templates/frontend/gateway/src/pages/hello-component.tsx +0 -23
- package/templates/frontend/gateway/src/pages/hello-ethereum.tsx +0 -23
- package/templates/frontend/gateway/src/pages/hello-social.tsx +0 -31
- package/templates/frontend/gateway/src/pages/index.tsx +0 -51
- package/templates/frontend/gateway/src/pages/nui.tsx +0 -25
- package/templates/frontend/gateway/src/stores/auth.ts +0 -29
- package/templates/frontend/gateway/src/stores/bos-loader.ts +0 -20
- package/templates/frontend/gateway/src/stores/current-component.ts +0 -11
- package/templates/frontend/gateway/src/stores/vm.ts +0 -24
- package/templates/frontend/gateway/src/styles/globals.css +0 -68
- package/templates/frontend/gateway/src/styles/theme.css +0 -129
- package/templates/frontend/gateway/src/utils/config.ts +0 -49
- package/templates/frontend/gateway/src/utils/form-validation.ts +0 -18
- package/templates/frontend/gateway/src/utils/keypom-options.ts +0 -59
- package/templates/frontend/gateway/src/utils/route/privateRoute.tsx +0 -20
- package/templates/frontend/gateway/src/utils/route/signedOutRoute.tsx +0 -21
- package/templates/frontend/gateway/src/utils/types.ts +0 -33
- package/templates/frontend/gateway/tsconfig.json +0 -24
- package/templates/frontend/vanilla/.env +0 -1
- package/templates/frontend/vanilla/index.html +0 -97
- package/templates/frontend/vanilla/index.js +0 -70
- package/templates/shared/template.gitignore +0 -31
- /package/templates/contracts/{rust → rs}/.cargo/config +0 -0
- /package/templates/contracts/{rust → rs}/rust-toolchain.toml +0 -0
- /package/templates/contracts/{js → ts}/package-lock.json +0 -0
- /package/templates/contracts/{js → ts}/src/contract.ts +0 -0
- /package/templates/contracts/{js → ts}/tsconfig.json +0 -0
- /package/templates/frontend/{gateway → next}/public/next.svg +0 -0
- /package/templates/frontend/{gateway → next}/public/vercel.svg +0 -0
- /package/templates/frontend/{gateway/public → next/src/app}/favicon.ico +0 -0
- /package/templates/{shared → frontend/vanilla}/.gitpod.yml +0 -0
- /package/templates/{shared → frontend/vanilla}/README.md +0 -0
- /package/templates/frontend/vanilla/{assets → src/assets}/favicon.ico +0 -0
- /package/templates/frontend/vanilla/{assets → src/assets}/logo-black.svg +0 -0
- /package/templates/frontend/vanilla/{assets → src/assets}/logo-white.svg +0 -0
- /package/templates/{integration-tests/rust-tests → sandbox-tests/sandbox-rs}/src/tests.rs +0 -0
- /package/templates/{integration-tests/js-tests → sandbox-tests/sandbox-ts}/ava.config.cjs +0 -0
- /package/templates/{integration-tests/js-tests → sandbox-tests/sandbox-ts}/package-lock.json +0 -0
- /package/templates/{integration-tests/js-tests → sandbox-tests/sandbox-ts}/src/main.ava.ts +0 -0
package/dist/app.js
CHANGED
|
@@ -31,11 +31,10 @@ const make_1 = require("./make");
|
|
|
31
31
|
const user_input_1 = require("./user-input");
|
|
32
32
|
const show = __importStar(require("./messages"));
|
|
33
33
|
(async function () {
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
34
|
+
const prompt = await (0, user_input_1.promptAndGetConfig)();
|
|
35
|
+
if (prompt === undefined)
|
|
36
36
|
return;
|
|
37
|
-
}
|
|
38
|
-
const { config: { projectName, contract, frontend, tests, install, }, projectPath, } = promptResult;
|
|
37
|
+
const { config: { projectName, contract, frontend, tests, install, }, projectPath, } = prompt;
|
|
39
38
|
show.creatingApp();
|
|
40
39
|
let createSuccess;
|
|
41
40
|
try {
|
|
@@ -44,8 +43,7 @@ const show = __importStar(require("./messages"));
|
|
|
44
43
|
frontend,
|
|
45
44
|
tests,
|
|
46
45
|
projectName,
|
|
47
|
-
|
|
48
|
-
rootDir: path_1.default.resolve(__dirname, '../templates'),
|
|
46
|
+
templatesDir: path_1.default.resolve(__dirname, '../templates'),
|
|
49
47
|
projectPath,
|
|
50
48
|
});
|
|
51
49
|
}
|
|
@@ -53,15 +51,12 @@ const show = __importStar(require("./messages"));
|
|
|
53
51
|
console.error(e);
|
|
54
52
|
createSuccess = false;
|
|
55
53
|
}
|
|
56
|
-
if (install) {
|
|
57
|
-
await (0, make_1.runDepsInstall)(projectPath);
|
|
58
|
-
}
|
|
59
54
|
if (createSuccess) {
|
|
55
|
+
install && await (0, make_1.runDepsInstall)(projectPath);
|
|
60
56
|
show.setupSuccess(projectName, contract, frontend, install);
|
|
61
57
|
}
|
|
62
58
|
else {
|
|
63
|
-
show.setupFailed();
|
|
64
|
-
return;
|
|
59
|
+
return show.setupFailed();
|
|
65
60
|
}
|
|
66
61
|
})();
|
|
67
62
|
//# sourceMappingURL=app.js.map
|
package/dist/make.js
CHANGED
|
@@ -26,104 +26,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.runDepsInstall = exports.copyDir = exports.
|
|
29
|
+
exports.runDepsInstall = exports.copyDir = exports.createProject = void 0;
|
|
30
30
|
const show = __importStar(require("./messages"));
|
|
31
31
|
const cross_spawn_1 = __importDefault(require("cross-spawn"));
|
|
32
32
|
const fs_1 = __importDefault(require("fs"));
|
|
33
33
|
const ncp_1 = require("ncp");
|
|
34
34
|
const path_1 = __importDefault(require("path"));
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
async function createProject({ contract, frontend, tests, projectPath, projectName, templatesDir }) {
|
|
36
|
+
if (contract !== 'none') {
|
|
37
|
+
await createContract({ contract, tests, projectPath, projectName, templatesDir });
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
await createGateway({ frontend, projectPath, projectName, templatesDir });
|
|
41
|
+
}
|
|
42
42
|
return true;
|
|
43
43
|
}
|
|
44
44
|
exports.createProject = createProject;
|
|
45
|
-
async function
|
|
46
|
-
//
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// copy tests - shared files
|
|
73
|
-
const sourceTestSharedDir = path_1.default.resolve(`${rootDir}/integration-tests/${tests}-tests`);
|
|
74
|
-
await copyDir(sourceTestSharedDir, targetTestDir, {
|
|
75
|
-
verbose,
|
|
76
|
-
skip: skip.map(f => path_1.default.join(sourceTestSharedDir, f))
|
|
77
|
-
});
|
|
45
|
+
async function createContract({ contract, tests, projectPath, projectName, templatesDir }) {
|
|
46
|
+
// contract folder
|
|
47
|
+
const sourceContractDir = path_1.default.resolve(templatesDir, 'contracts', contract);
|
|
48
|
+
const targetContractDir = projectPath;
|
|
49
|
+
fs_1.default.mkdirSync(targetContractDir, { recursive: true });
|
|
50
|
+
await copyDir(sourceContractDir, targetContractDir);
|
|
51
|
+
// copy sandbox-test dir
|
|
52
|
+
const targetTestDir = path_1.default.resolve(projectPath, `sandbox-${tests}`);
|
|
53
|
+
const sourceTestDir = path_1.default.resolve(`${templatesDir}/sandbox-tests/sandbox-${tests}`);
|
|
54
|
+
fs_1.default.mkdirSync(targetTestDir);
|
|
55
|
+
await copyDir(sourceTestDir, targetTestDir);
|
|
56
|
+
if (contract === 'rs') {
|
|
57
|
+
if (tests === 'rs') {
|
|
58
|
+
// leave only one test script
|
|
59
|
+
fs_1.default.unlinkSync(path_1.default.resolve(projectPath, 'test-ts.sh'));
|
|
60
|
+
fs_1.default.renameSync(path_1.default.resolve(projectPath, 'test-rs.sh'), path_1.default.resolve(projectPath, 'test.sh'));
|
|
61
|
+
// add workspace to Cargo.toml
|
|
62
|
+
const cargoTomlPath = path_1.default.resolve(projectPath, 'Cargo.toml');
|
|
63
|
+
const cargoToml = fs_1.default.readFileSync(cargoTomlPath).toString();
|
|
64
|
+
const cargoTomlWithWorkspace = cargoToml + '\n[workspace]\nmembers = ["sandbox-rs"]';
|
|
65
|
+
fs_1.default.writeFileSync(cargoTomlPath, cargoTomlWithWorkspace);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
// leave only one test script
|
|
69
|
+
fs_1.default.unlinkSync(path_1.default.resolve(projectPath, 'test-rs.sh'));
|
|
70
|
+
fs_1.default.renameSync(path_1.default.resolve(projectPath, 'test-ts.sh'), path_1.default.resolve(projectPath, 'test.sh'));
|
|
71
|
+
}
|
|
78
72
|
}
|
|
79
|
-
// add .gitignore
|
|
80
|
-
await (0, exports.renameFile)(`${projectPath}/template.gitignore`, `${projectPath}/.gitignore`);
|
|
81
73
|
}
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
reject(err);
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
resolve();
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
exports.renameFile = renameFile;
|
|
74
|
+
async function createGateway({ frontend, projectPath, projectName, templatesDir }) {
|
|
75
|
+
const sourceFrontendDir = path_1.default.resolve(`${templatesDir}/frontend/${frontend}`);
|
|
76
|
+
const targetFrontendDir = path_1.default.resolve(`${projectPath}`);
|
|
77
|
+
fs_1.default.mkdirSync(targetFrontendDir, { recursive: true });
|
|
78
|
+
await copyDir(sourceFrontendDir, targetFrontendDir);
|
|
79
|
+
}
|
|
96
80
|
// Wrap `ncp` tool to wait for the copy to finish when using `await`
|
|
97
|
-
|
|
98
|
-
function copyDir(source, dest, { skip, verbose }) {
|
|
81
|
+
function copyDir(source, dest) {
|
|
99
82
|
return new Promise((resolve, reject) => {
|
|
100
|
-
|
|
101
|
-
const skipped = [];
|
|
102
|
-
const filter = skip && function (filename) {
|
|
103
|
-
const shouldCopy = !skip.find(f => filename.includes(f));
|
|
104
|
-
shouldCopy ? copied.push(filename) : skipped.push(filename);
|
|
105
|
-
return !skip.find(f => filename.includes(f));
|
|
106
|
-
};
|
|
107
|
-
(0, ncp_1.ncp)(source, dest, { filter }, err => {
|
|
108
|
-
if (err) {
|
|
109
|
-
reject(err);
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (verbose) {
|
|
113
|
-
console.log('Copied:');
|
|
114
|
-
copied.forEach(f => console.log(' ' + f));
|
|
115
|
-
console.log('Skipped:');
|
|
116
|
-
skipped.forEach(f => console.log(' ' + f));
|
|
117
|
-
}
|
|
118
|
-
resolve();
|
|
119
|
-
});
|
|
83
|
+
(0, ncp_1.ncp)(source, dest, {}, err => err ? reject(err) : resolve());
|
|
120
84
|
});
|
|
121
85
|
}
|
|
122
86
|
exports.copyDir = copyDir;
|
|
123
87
|
async function runDepsInstall(projectPath) {
|
|
124
88
|
show.depsInstall();
|
|
125
|
-
|
|
126
|
-
await new Promise((resolve, reject) => (0, cross_spawn_1.default)('npm', npmCommandArgs, {
|
|
89
|
+
await new Promise((resolve, reject) => (0, cross_spawn_1.default)('npm', ['install'], {
|
|
127
90
|
cwd: projectPath,
|
|
128
91
|
stdio: 'inherit',
|
|
129
92
|
}).on('close', (code) => {
|
package/dist/messages.js
CHANGED
|
@@ -3,7 +3,7 @@ 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.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;
|
|
6
|
+
exports.depsInstallError = exports.depsInstall = exports.creatingApp = exports.directoryExists = exports.windowsWarning = exports.unsupportedNodeVersion = exports.argsError = exports.gatewayInstructions = exports.contractInstructions = 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
9
|
if (process.env.NEAR_NO_COLOR) {
|
|
@@ -11,46 +11,54 @@ if (process.env.NEAR_NO_COLOR) {
|
|
|
11
11
|
}
|
|
12
12
|
const show = (...args) => console.log(...args);
|
|
13
13
|
exports.show = show;
|
|
14
|
-
const welcome = () => (0, exports.show)((0, chalk_1.default) `
|
|
15
|
-
👋 {bold {green Welcome to NEAR!}} Learn more: https://docs.near.org/
|
|
16
|
-
🔧 Let's get your dApp ready.
|
|
14
|
+
const welcome = () => (0, exports.show)((0, chalk_1.default) `
|
|
17
15
|
{blue ======================================================}
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
👋 {bold {green Welcome to Near!}} Learn more: https://docs.near.org/
|
|
17
|
+
🔧 Let's get your project ready.
|
|
18
|
+
{blue ======================================================}
|
|
19
|
+
(${tracking_1.trackingMessage})`);
|
|
20
20
|
exports.welcome = welcome;
|
|
21
21
|
const setupFailed = () => (0, exports.show)((0, chalk_1.default) `{bold {red ==========================================}}
|
|
22
|
-
{red ⛔️ There was a problem during
|
|
22
|
+
{red ⛔️ There was a problem during the project setup}.
|
|
23
23
|
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) => contract === 'none' ? '' : (0, chalk_1.default) `
|
|
27
|
+
const successContractToText = (contract) => contract === 'none' ? '' : (0, chalk_1.default) `a smart contract in {bold ${contract === 'rs' ? 'Rust' : 'Typescript'}}`;
|
|
28
28
|
exports.successContractToText = successContractToText;
|
|
29
|
-
const successFrontendToText = (frontend) => frontend === 'none' ? '' : (0, chalk_1.default) `
|
|
29
|
+
const successFrontendToText = (frontend) => frontend === 'none' ? '' : (0, chalk_1.default) `a gateway using ${frontend === 'next' ? 'NextJS + React' : 'Vanilla-JS'}`;
|
|
30
30
|
exports.successFrontendToText = successFrontendToText;
|
|
31
31
|
const setupSuccess = (projectName, contract, frontend, install) => (0, exports.show)((0, chalk_1.default) `
|
|
32
32
|
{green ======================================================}
|
|
33
|
-
✅ Success! Created '${projectName}'
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
✅ Success! Created '${projectName}', ${(0, exports.successContractToText)(contract)}${(0, exports.successFrontendToText)(frontend)}.
|
|
34
|
+
${contract === 'rs' ? (0, chalk_1.default) `🦀 If you are new to Rust please visit {bold {green https://www.rust-lang.org }}\n` : ''}
|
|
35
|
+
{bold {bgYellow {black Next steps}}}:
|
|
36
|
+
${(0, exports.contractInstructions)(projectName, contract, install)}${(0, exports.gatewayInstructions)(projectName, frontend, install)}`);
|
|
37
|
+
exports.setupSuccess = setupSuccess;
|
|
38
|
+
const contractInstructions = (projectName, contract, install) => contract === 'none' ? '' : (0, chalk_1.default) `
|
|
37
39
|
- {inverse Navigate to your project}:
|
|
38
40
|
{blue cd {bold ${projectName}}}
|
|
39
|
-
|
|
41
|
+
${contract === 'ts' && !install ? (0, chalk_1.default) ` - {inverse Install all dependencies}
|
|
40
42
|
{blue npm {bold install}}` : 'Then:'}
|
|
41
43
|
- {inverse Build your contract}:
|
|
42
|
-
{blue npm {bold run build}}
|
|
43
|
-
- {inverse Test your contract} in
|
|
44
|
-
{blue npm {bold test}}
|
|
44
|
+
${contract === 'ts' ? (0, chalk_1.default) `{blue npm {bold run build}}` : (0, chalk_1.default) `{blue {bold ./build.sh}}`}
|
|
45
|
+
- {inverse Test your contract} in the Sandbox:
|
|
46
|
+
${contract === 'ts' ? (0, chalk_1.default) `{blue npm {bold run test}}` : (0, chalk_1.default) `{blue {bold ./test.sh}}`}
|
|
45
47
|
- {inverse Deploy your contract} to NEAR TestNet with a temporary dev account:
|
|
46
|
-
{blue npm {bold run deploy}}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
${contract === 'ts' ? (0, chalk_1.default) `{blue npm {bold run deploy}}` : (0, chalk_1.default) `{blue {bold ./deploy.sh}}`}
|
|
49
|
+
🧠 Read {bold {greenBright README.md}} to explore further`;
|
|
50
|
+
exports.contractInstructions = contractInstructions;
|
|
51
|
+
const gatewayInstructions = (projectName, frontend, install) => frontend === 'none' ? '' : (0, chalk_1.default) `
|
|
52
|
+
- {inverse Navigate to your project}:
|
|
53
|
+
{blue cd {bold ${projectName}}}
|
|
54
|
+
${!install ? (0, chalk_1.default) ` - {inverse Install all dependencies}
|
|
55
|
+
{blue pnpm {bold install}}` : 'Then:'}
|
|
56
|
+
- {inverse Start your app}:
|
|
57
|
+
{blue pnpm {bold run dev}}`;
|
|
58
|
+
exports.gatewayInstructions = gatewayInstructions;
|
|
51
59
|
const argsError = () => (0, exports.show)((0, chalk_1.default) `{red Arguments error}
|
|
52
60
|
Run {blue npx create-near-app} without arguments, or use:
|
|
53
|
-
npx create-near-app <projectName> --
|
|
61
|
+
npx create-near-app <projectName> --frontend next|vanilla|none --contract rs|ts|none --tests rs|ts|none`);
|
|
54
62
|
exports.argsError = argsError;
|
|
55
63
|
const unsupportedNodeVersion = (supported) => (0, exports.show)((0, chalk_1.default) `{red We support node.js version ${supported} or later}`);
|
|
56
64
|
exports.unsupportedNodeVersion = unsupportedNodeVersion;
|
package/dist/package-json.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.buildPackagetson = void 0;
|
|
4
|
+
function buildPackagetson({ contract, frontend, tests, projectName }) {
|
|
5
5
|
const result = basePackage({
|
|
6
6
|
contract, frontend, tests, projectName,
|
|
7
7
|
});
|
|
8
8
|
return result;
|
|
9
9
|
}
|
|
10
|
-
exports.
|
|
10
|
+
exports.buildPackagetson = buildPackagetson;
|
|
11
11
|
function basePackage({ contract, frontend, tests, projectName }) {
|
|
12
12
|
const hasFrontend = frontend !== 'none';
|
|
13
13
|
return {
|
|
@@ -42,11 +42,11 @@ const buildScript = (hasFrontend) => hasFrontend ? {
|
|
|
42
42
|
const buildContractScriptName = 'build:contract';
|
|
43
43
|
const buildContractScript = (contract) => {
|
|
44
44
|
switch (contract) {
|
|
45
|
-
case '
|
|
45
|
+
case 'ts':
|
|
46
46
|
return {
|
|
47
47
|
[buildContractScriptName]: 'cd contract && npm run build',
|
|
48
48
|
};
|
|
49
|
-
case '
|
|
49
|
+
case 'rs':
|
|
50
50
|
return {
|
|
51
51
|
[buildContractScriptName]: 'cd contract && ./build.sh',
|
|
52
52
|
};
|
|
@@ -58,11 +58,11 @@ const buildContractScript = (contract) => {
|
|
|
58
58
|
};
|
|
59
59
|
const deployScript = (contract) => {
|
|
60
60
|
switch (contract) {
|
|
61
|
-
case '
|
|
61
|
+
case 'ts':
|
|
62
62
|
return {
|
|
63
63
|
'deploy': 'cd contract && npm run deploy',
|
|
64
64
|
};
|
|
65
|
-
case '
|
|
65
|
+
case 'rs':
|
|
66
66
|
return {
|
|
67
67
|
'deploy': 'cd contract && ./deploy.sh',
|
|
68
68
|
};
|
|
@@ -74,9 +74,9 @@ const deployScript = (contract) => {
|
|
|
74
74
|
};
|
|
75
75
|
const unitTestScripts = (contract) => {
|
|
76
76
|
switch (contract) {
|
|
77
|
-
case '
|
|
77
|
+
case 'ts':
|
|
78
78
|
return { 'test:unit': 'cd contract && npm test' };
|
|
79
|
-
case '
|
|
79
|
+
case 'rs':
|
|
80
80
|
return { 'test:unit': 'cd contract && cargo test' };
|
|
81
81
|
case 'none':
|
|
82
82
|
return { 'test:unit': 'echo "No contract to test"' };
|
|
@@ -88,19 +88,19 @@ const integrationTestScripts = (contract, tests) => {
|
|
|
88
88
|
}
|
|
89
89
|
let wasm_path = '';
|
|
90
90
|
switch (contract) {
|
|
91
|
-
case '
|
|
91
|
+
case 'ts':
|
|
92
92
|
wasm_path = 'contract/build/hello_near.wasm';
|
|
93
93
|
break;
|
|
94
|
-
case '
|
|
94
|
+
case 'rs':
|
|
95
95
|
wasm_path = 'contract/target/wasm32-unknown-unknown/release/hello_near.wasm';
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
let run_test = '';
|
|
99
99
|
switch (tests) {
|
|
100
|
-
case '
|
|
100
|
+
case 'ts':
|
|
101
101
|
run_test = `npm test -- -- "./${wasm_path}"`;
|
|
102
102
|
break;
|
|
103
|
-
case '
|
|
103
|
+
case 'rs':
|
|
104
104
|
run_test = `cargo run --example integration-tests "../${wasm_path}"`;
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
@@ -110,13 +110,13 @@ const integrationTestScripts = (contract, tests) => {
|
|
|
110
110
|
};
|
|
111
111
|
const npmInstallScript = (contract, hasFrontend, tests) => {
|
|
112
112
|
const frontend_install = hasFrontend ? 'cd frontend && npm install && cd ..' : 'echo no frontend';
|
|
113
|
-
const test_install = (tests === '
|
|
113
|
+
const test_install = (contract !== 'none' && tests === 'ts') ? 'cd integration-tests && npm install && cd ..' : 'echo no ts test';
|
|
114
114
|
let contract_install = '';
|
|
115
115
|
switch (contract) {
|
|
116
|
-
case '
|
|
116
|
+
case 'ts':
|
|
117
117
|
contract_install = 'cd contract && npm install';
|
|
118
118
|
break;
|
|
119
|
-
case '
|
|
119
|
+
case 'rs':
|
|
120
120
|
contract_install = 'echo rs contract';
|
|
121
121
|
break;
|
|
122
122
|
case 'none':
|
package/dist/tracking.js
CHANGED
|
@@ -8,7 +8,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const mixpanel_1 = __importDefault(require("mixpanel"));
|
|
9
9
|
const MIXPANEL_TOKEN = 'df164f13212cbb0dfdae991da60e87f2';
|
|
10
10
|
const tracker = mixpanel_1.default.init(MIXPANEL_TOKEN);
|
|
11
|
-
exports.trackingMessage = (0, chalk_1.default) `
|
|
11
|
+
exports.trackingMessage = (0, chalk_1.default) `Near collects anonymous information on the commands used. No personal information that could identify you is shared`;
|
|
12
12
|
// TODO: track different failures & install usage
|
|
13
13
|
const trackUsage = async (frontend, contract) => {
|
|
14
14
|
// prevents logging from CI
|
package/dist/types.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TESTING_FRAMEWORKS = exports.FRONTENDS = exports.CONTRACTS = void 0;
|
|
4
|
-
exports.CONTRACTS = ['
|
|
5
|
-
exports.FRONTENDS = ['
|
|
6
|
-
exports.TESTING_FRAMEWORKS = ['
|
|
3
|
+
exports.APPS = exports.TESTING_FRAMEWORKS = exports.FRONTENDS = exports.CONTRACTS = void 0;
|
|
4
|
+
exports.CONTRACTS = ['ts', 'rs', 'none'];
|
|
5
|
+
exports.FRONTENDS = ['next', 'vanilla', 'none'];
|
|
6
|
+
exports.TESTING_FRAMEWORKS = ['rs', 'ts', 'none'];
|
|
7
|
+
exports.APPS = ['contract', 'gateway'];
|
|
7
8
|
//# sourceMappingURL=types.js.map
|
package/dist/user-input.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.projectPath = exports.promptAndGetConfig = exports.
|
|
29
|
+
exports.projectPath = exports.promptAndGetConfig = exports.getUserAnswers = exports.validateUserArgs = exports.getUserArgs = void 0;
|
|
30
30
|
const types_1 = require("./types");
|
|
31
31
|
const chalk_1 = __importDefault(require("chalk"));
|
|
32
32
|
const prompts_1 = __importDefault(require("prompts"));
|
|
@@ -38,10 +38,11 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
38
38
|
async function getUserArgs() {
|
|
39
39
|
commander_1.program
|
|
40
40
|
.argument('[projectName]')
|
|
41
|
-
.option('--contract
|
|
42
|
-
.option('--frontend
|
|
43
|
-
.option('--tests
|
|
44
|
-
.option('--install')
|
|
41
|
+
.option('--contract [ts|rs|none]')
|
|
42
|
+
.option('--frontend [next|vanilla|none]')
|
|
43
|
+
.option('--tests [rs|ts|none]')
|
|
44
|
+
.option('--install')
|
|
45
|
+
.addHelpText('after', 'You can create a frontend or a contract with tests');
|
|
45
46
|
commander_1.program.parse();
|
|
46
47
|
const options = commander_1.program.opts();
|
|
47
48
|
const [projectName] = commander_1.program.args;
|
|
@@ -74,120 +75,111 @@ function validateUserArgs(args) {
|
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
exports.validateUserArgs = validateUserArgs;
|
|
78
|
+
const appChoices = [
|
|
79
|
+
{ title: 'A Near Smart Contract', description: 'A smart contract to be deployed in the Near Blockchain', value: 'contract' },
|
|
80
|
+
{ title: 'A Near Gateway (Web App)', description: 'A multi-chain App that talks with Near contracts and Near components', value: 'gateway' },
|
|
81
|
+
];
|
|
77
82
|
const contractChoices = [
|
|
78
|
-
{ title: '
|
|
79
|
-
{ title: '
|
|
80
|
-
{ title: 'No', description: 'You are not building a Near smart contract', value: 'none' },
|
|
83
|
+
{ title: 'JS/TS Contract', description: 'A Near contract written in javascript/typescript', value: 'ts' },
|
|
84
|
+
{ title: 'Rust Contract', description: 'A Near contract written in Rust', value: 'rs' },
|
|
81
85
|
];
|
|
82
86
|
const testsChoices = [
|
|
83
|
-
{ title: 'Tests written in Rust', value: '
|
|
84
|
-
{ title: 'Tests written in
|
|
87
|
+
{ title: 'Tests written in Rust', value: 'rs' },
|
|
88
|
+
{ title: 'Tests written in Typescript', value: 'ts' },
|
|
85
89
|
];
|
|
86
90
|
const frontendChoices = [
|
|
87
|
-
{ title: '
|
|
88
|
-
{ title: 'Vanilla
|
|
89
|
-
{ title: 'No frontend', description: 'Build a smart contract with no frontend', value: 'none' },
|
|
91
|
+
{ title: 'NextJs + React', description: 'A composable app built using Next.js, React and Near components', value: 'next' },
|
|
92
|
+
{ title: 'Vanilla JS', description: 'A framework-less web app with limited capabilities.', value: 'vanilla' },
|
|
90
93
|
];
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
const appPrompt = {
|
|
95
|
+
type: 'select',
|
|
96
|
+
name: 'app',
|
|
97
|
+
message: 'What do you want to build?',
|
|
98
|
+
choices: appChoices,
|
|
99
|
+
};
|
|
100
|
+
const frontendPrompt = {
|
|
101
|
+
type: 'select',
|
|
102
|
+
name: 'frontend',
|
|
103
|
+
message: 'Select a framework for your frontend (Gateway)',
|
|
104
|
+
choices: frontendChoices,
|
|
105
|
+
};
|
|
106
|
+
const contractPrompt = [
|
|
98
107
|
{
|
|
99
108
|
type: 'select',
|
|
100
109
|
name: 'contract',
|
|
101
|
-
message: '
|
|
110
|
+
message: 'Select a smart contract template for your project',
|
|
102
111
|
choices: contractChoices,
|
|
103
112
|
},
|
|
104
113
|
{
|
|
105
|
-
type: prev => prev === '
|
|
114
|
+
type: prev => prev === 'rs' ? 'select' : null,
|
|
106
115
|
name: 'tests',
|
|
107
116
|
message: 'Sandbox Testing: Which language do you prefer to test your contract?',
|
|
108
117
|
choices: testsChoices,
|
|
109
|
-
}
|
|
110
|
-
{
|
|
111
|
-
type: 'text',
|
|
112
|
-
name: 'projectName',
|
|
113
|
-
message: 'Name your project (this will create a directory with that name)',
|
|
114
|
-
initial: 'hello-near',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
type: 'confirm',
|
|
118
|
-
name: 'install',
|
|
119
|
-
message: (0, chalk_1.default) `Run {bold {blue 'npm install'}} now?`,
|
|
120
|
-
initial: true,
|
|
121
|
-
},
|
|
118
|
+
}
|
|
122
119
|
];
|
|
120
|
+
const namePrompts = {
|
|
121
|
+
type: 'text',
|
|
122
|
+
name: 'projectName',
|
|
123
|
+
message: 'Name your project (we will create a directory with that name)',
|
|
124
|
+
initial: 'hello-near',
|
|
125
|
+
};
|
|
126
|
+
const npmPrompt = {
|
|
127
|
+
type: 'confirm',
|
|
128
|
+
name: 'install',
|
|
129
|
+
message: (0, chalk_1.default) `Run {bold {blue 'npm install'}} now?`,
|
|
130
|
+
initial: true,
|
|
131
|
+
};
|
|
132
|
+
const promptUser = async (prompts) => {
|
|
133
|
+
// Prompt, and exit if user cancels
|
|
134
|
+
return (0, prompts_1.default)(prompts, { onCancel: () => process.exit(0) });
|
|
135
|
+
};
|
|
123
136
|
async function getUserAnswers() {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
exports.getUserAnswers = getUserAnswers;
|
|
131
|
-
async function showProjectNamePrompt() {
|
|
132
|
-
const [, , , projectName] = userPrompts;
|
|
133
|
-
const answers = await (0, prompts_1.default)([projectName]);
|
|
134
|
-
return answers;
|
|
135
|
-
}
|
|
136
|
-
exports.showProjectNamePrompt = showProjectNamePrompt;
|
|
137
|
-
function userAnswersAreValid(answers) {
|
|
138
|
-
const { contract, frontend, projectName, tests } = answers;
|
|
139
|
-
if ([contract, frontend, projectName, tests].includes(undefined)) {
|
|
140
|
-
return false;
|
|
137
|
+
// Either the user wants a gateway or a contract
|
|
138
|
+
const { app } = await promptUser(appPrompt);
|
|
139
|
+
if (app === 'gateway') {
|
|
140
|
+
// If gateway, ask for the framework to use
|
|
141
|
+
const { frontend, projectName, install } = await promptUser([frontendPrompt, namePrompts, npmPrompt]);
|
|
142
|
+
return { frontend, contract: 'none', tests: 'none', projectName, install };
|
|
141
143
|
}
|
|
142
144
|
else {
|
|
143
|
-
|
|
145
|
+
// If contract, ask for the language for the contract and tests
|
|
146
|
+
let { contract, tests } = await promptUser(contractPrompt);
|
|
147
|
+
tests = contract === 'ts' ? 'ts' : tests;
|
|
148
|
+
const { projectName } = await promptUser(namePrompts);
|
|
149
|
+
const install = contract === 'ts' ? (await promptUser(npmPrompt)).install : false;
|
|
150
|
+
return { frontend: 'none', contract, tests, projectName, install };
|
|
144
151
|
}
|
|
145
152
|
}
|
|
146
|
-
exports.
|
|
153
|
+
exports.getUserAnswers = getUserAnswers;
|
|
147
154
|
async function promptAndGetConfig() {
|
|
148
|
-
let config = null;
|
|
149
|
-
let isFromPrompts = false;
|
|
150
|
-
// process cli args
|
|
151
|
-
const args = await getUserArgs();
|
|
152
|
-
const argsValid = validateUserArgs(args);
|
|
153
|
-
if (argsValid === 'error') {
|
|
154
|
-
show.argsError();
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
else if (argsValid === 'ok') {
|
|
158
|
-
config = args;
|
|
159
|
-
}
|
|
160
|
-
show.welcome();
|
|
161
|
-
const nodeVersion = process.version;
|
|
162
155
|
const supportedNodeVersion = require('../package.json').engines.node;
|
|
163
|
-
if (!semver_1.default.satisfies(
|
|
164
|
-
show.unsupportedNodeVersion(supportedNodeVersion);
|
|
165
|
-
// TODO: track unsupported versions
|
|
166
|
-
return null;
|
|
156
|
+
if (!semver_1.default.satisfies(process.version, supportedNodeVersion)) {
|
|
157
|
+
return show.unsupportedNodeVersion(supportedNodeVersion);
|
|
167
158
|
}
|
|
168
159
|
if (process.platform === 'win32') {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
160
|
+
return show.windowsWarning();
|
|
161
|
+
}
|
|
162
|
+
// process cli args
|
|
163
|
+
let args = await getUserArgs();
|
|
164
|
+
if (args.contract && (!args.tests || args.frontend)) {
|
|
165
|
+
return show.argsError();
|
|
166
|
+
}
|
|
167
|
+
if (args.frontend && (args.tests || args.contract)) {
|
|
168
|
+
return show.argsError();
|
|
172
169
|
}
|
|
173
|
-
//
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (!userAnswersAreValid(userInput)) {
|
|
178
|
-
throw new Error(`Invalid prompt. ${JSON.stringify(userInput)}`);
|
|
179
|
-
}
|
|
180
|
-
config = userInput;
|
|
170
|
+
// If no args, prompt user
|
|
171
|
+
if (!args.contract && !args.frontend) {
|
|
172
|
+
show.welcome();
|
|
173
|
+
args = await getUserAnswers();
|
|
181
174
|
}
|
|
182
|
-
|
|
175
|
+
// track user input
|
|
176
|
+
const { frontend, contract } = args;
|
|
183
177
|
(0, tracking_1.trackUsage)(frontend, contract);
|
|
184
|
-
let path = (0, exports.projectPath)(
|
|
185
|
-
// If dir exists warn and exit
|
|
178
|
+
let path = (0, exports.projectPath)(args.projectName);
|
|
186
179
|
if (fs_1.default.existsSync(path)) {
|
|
187
|
-
show.directoryExists(path);
|
|
188
|
-
return null;
|
|
180
|
+
return show.directoryExists(path);
|
|
189
181
|
}
|
|
190
|
-
return { config, projectPath: path
|
|
182
|
+
return { config: args, projectPath: path };
|
|
191
183
|
}
|
|
192
184
|
exports.promptAndGetConfig = promptAndGetConfig;
|
|
193
185
|
const projectPath = (projectName) => `${process.cwd()}/${projectName}`;
|
package/package.json
CHANGED