create-near-app 4.0.0-beta.1.0 → 4.0.0-beta.2.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 CHANGED
@@ -1,30 +1,28 @@
1
- create-near-app
1
+ # Create NEAR App
2
2
  ===============
3
3
  [![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](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
- Using [npm's npx](https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner):
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
- Develop your own Dapp
37
- =====================
36
+ ### Using CLI arguments to run `create-near-app`
38
37
 
39
- Follow the instructions in the README.md in the project you just created! 🚀
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 `yarn` to install dependencies and `yarn dev` to run the local development server, just like you can in a new app created with `create-near-app`
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
- about commit messages
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
- yarn release
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,52 @@
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 messages_1 = require("./messages");
13
- (async function run() {
14
- let config = null;
15
- let configIsFromPrompts = false;
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();
24
- return;
25
- }
26
- else if (argsValid === 'ok') {
27
- config = args;
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
32
+ const show = __importStar(require("./messages"));
33
+ (async function () {
34
+ const promptResult = await (0, user_input_1.promptAndGetConfig)();
35
+ if (promptResult === null) {
36
36
  return;
37
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
- }
38
+ const { config: { projectName, contract, frontend, tests, install }, projectPath, isFromPrompts, } = promptResult;
39
+ show.creatingApp();
40
+ if (contract === 'assemblyscript') {
41
+ show.assemblyscriptWarning();
63
42
  }
64
- // Create the project
65
43
  let createSuccess;
66
44
  try {
67
45
  createSuccess = await (0, make_1.createProject)({
68
46
  contract,
69
47
  frontend,
48
+ tests,
70
49
  projectName,
71
- supportsSandbox,
72
50
  verbose: false,
73
51
  rootDir: path_1.default.resolve(__dirname, '../templates'),
74
52
  projectPath,
@@ -79,16 +57,16 @@ const messages_1 = require("./messages");
79
57
  createSuccess = false;
80
58
  }
81
59
  if (createSuccess) {
82
- messages_1.show.setupSuccess(projectPath, contract, frontend);
60
+ show.setupSuccess(projectPath, contract, frontend);
83
61
  }
84
62
  else {
85
- messages_1.show.setupFailed();
63
+ show.setupFailed();
86
64
  return;
87
65
  }
88
66
  if (install) {
89
67
  await (0, make_1.runDepsInstall)(projectPath);
90
68
  }
91
- else if (configIsFromPrompts) {
69
+ else if (isFromPrompts) {
92
70
  const { depsInstall } = await (0, user_input_1.showDepsInstallPrompt)();
93
71
  if (depsInstall) {
94
72
  await (0, make_1.runDepsInstall)(projectPath);
package/dist/checks.js CHANGED
@@ -25,8 +25,8 @@ exports.postMessage = postMessage;
25
25
  const AS_NOT_SUPPORTED_MSG = (0, chalk_1.default) `
26
26
  {yellow Warning} NEAR-SDK-AS might {bold {red not be compatible}} with your system
27
27
  `;
28
- async function asPreMessage({ supportsSandbox }) {
29
- if (!supportsSandbox) {
28
+ async function asPreMessage({ tests }) {
29
+ if (tests === 'workspaces') {
30
30
  console.log(AS_NOT_SUPPORTED_MSG);
31
31
  return true;
32
32
  }
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 messages_1 = require("./messages");
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
- // Method to create the project folder
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, supportsSandbox });
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, projectName, supportsSandbox });
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, supportsSandbox }) {
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
@@ -47,21 +60,12 @@ async function createFiles({ contract, frontend, projectPath, verbose, rootDir,
47
60
  skip: skip.map(f => path_1.default.join(contractSourceDir, f))
48
61
  });
49
62
  // copy tests
50
- const testFramework = supportsSandbox ? 'workspaces-tests' : 'classic-tests';
51
63
  let sourceTestDir = `${rootDir}/integration-tests`;
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
- }
64
+ if (tests === 'js') {
65
+ sourceTestDir = path_1.default.resolve(sourceTestDir, 'workspaces-tests/ts');
62
66
  }
63
67
  else {
64
- sourceTestDir = path_1.default.resolve(sourceTestDir, 'classic-tests');
68
+ sourceTestDir = path_1.default.resolve(sourceTestDir, 'workspaces-tests/rs');
65
69
  }
66
70
  await copyDir(sourceTestDir, `${projectPath}/integration-tests/`, {
67
71
  verbose,
@@ -112,14 +116,14 @@ function copyDir(source, dest, { skip, verbose }) {
112
116
  }
113
117
  exports.copyDir = copyDir;
114
118
  async function runDepsInstall(projectPath) {
115
- messages_1.show.depsInstall();
116
- const npmCommandArgs = ['deps-install'];
117
- await new Promise((resolve, reject) => (0, cross_spawn_1.default)('yarn', npmCommandArgs, {
119
+ show.depsInstall();
120
+ const npmCommandArgs = ['run', 'deps-install'];
121
+ await new Promise((resolve, reject) => (0, cross_spawn_1.default)('npm', npmCommandArgs, {
118
122
  cwd: projectPath,
119
123
  stdio: 'inherit',
120
124
  }).on('close', (code) => {
121
125
  if (code !== 0) {
122
- messages_1.show.depsInstallError();
126
+ show.depsInstallError();
123
127
  reject(code);
124
128
  }
125
129
  else {
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.show = exports.log = void 0;
6
+ exports.depsInstallError = exports.depsInstall = exports.creatingApp = exports.directoryExists = exports.assemblyscriptWarning = exports.windowsWarning = exports.unsupportedNodeVersion = exports.argsError = exports.setupSuccess = exports.successFrontendToText = exports.successContractToText = exports.setupFailed = exports.welcome = exports.log = void 0;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const tracking_1 = require("./tracking");
9
9
  const log = (...args) => console.log(...args);
@@ -14,33 +14,43 @@ const welcome = () => (0, exports.log)((0, chalk_1.default) `{blue =============
14
14
  {blue ======================================================}
15
15
  (${tracking_1.trackingMessage})
16
16
  `);
17
+ exports.welcome = welcome;
17
18
  const setupFailed = () => (0, exports.log)((0, chalk_1.default) `{bold {red ==========================================}}
18
19
  {red ⛔️ There was a problem during NEAR project setup}.
19
20
  Please refer to https://github.com/near/create-near-app README to troubleshoot.
20
21
  Notice: some platforms aren't supported (yet).
21
22
  {bold {red ==========================================}}`);
23
+ exports.setupFailed = setupFailed;
22
24
  const successContractToText = (contract) => (0, chalk_1.default) `with a smart contract in {bold ${contract === 'rust' ? 'Rust' : contract === 'js' ? 'JavaScript' : 'AssemblyScript'}}`;
25
+ exports.successContractToText = successContractToText;
23
26
  const successFrontendToText = (frontend) => frontend === 'none' ? '' : (0, chalk_1.default) ` and a frontend template${frontend === 'react' ? (0, chalk_1.default) `{bold in React.js}` : ''}`;
27
+ exports.successFrontendToText = successFrontendToText;
24
28
  const setupSuccess = (projectName, contract, frontend) => (0, exports.log)((0, chalk_1.default) `
25
29
  ✅ Success! Created '${projectName}'
26
- ${successContractToText(contract)}${successFrontendToText(frontend)}.
30
+ ${(0, exports.successContractToText)(contract)}${(0, exports.successFrontendToText)(frontend)}.
27
31
  🧠 See {bold {green README.md}} to get started.
28
- ${contract === 'rust' ? (0, chalk_1.default) `🦀 If you are new to Rust please visit {bold {green https://www.rust-lang.org }}\n` : '\n'}
32
+ ${contract === 'rust' ? (0, chalk_1.default) `🦀 If you are new to Rust please visit {bold {green https://www.rust-lang.org }}` : ''}
29
33
  Happy Hacking! 👍
30
34
  {blue ======================================================}`);
35
+ exports.setupSuccess = setupSuccess;
31
36
  const argsError = () => (0, exports.log)((0, chalk_1.default) `{red Arguments error}
32
37
  Run {blue npx create-near-app} without arguments, or use:
33
- npx create-near-app <projectName> --contract rust|js|assemblyscript --frontend react|vanilla|none`);
38
+ npx create-near-app <projectName> --contract rust|js|assemblyscript --frontend react|vanilla|none --tests js|rust`);
39
+ exports.argsError = argsError;
34
40
  const unsupportedNodeVersion = (supported) => (0, exports.log)((0, chalk_1.default) `{red We support node.js version ${supported} or later}`);
41
+ exports.unsupportedNodeVersion = unsupportedNodeVersion;
42
+ const windowsWarning = () => (0, exports.log)((0, chalk_1.default) `👉 Notice: On Windows we recommend using WSL.`);
43
+ exports.windowsWarning = windowsWarning;
44
+ const assemblyscriptWarning = () => (0, exports.log)((0, chalk_1.default) `👉 Notice: AssemblyScript is not supported on all platforms.`);
45
+ exports.assemblyscriptWarning = assemblyscriptWarning;
35
46
  const directoryExists = (dirName) => (0, exports.log)((0, chalk_1.default) `{red This directory already exists! ${dirName}}`);
36
- const creatingApp = () => (0, exports.log)((0, chalk_1.default) `...creating a new NEAR app...`);
47
+ exports.directoryExists = directoryExists;
48
+ const creatingApp = () => (0, exports.log)((0, chalk_1.default) `\n...creating a new NEAR app...`);
49
+ exports.creatingApp = creatingApp;
37
50
  const depsInstall = () => (0, exports.log)((0, chalk_1.default) `
38
51
  {green Installing dependencies in a few folders, this might take a while...}
39
52
  `);
53
+ exports.depsInstall = depsInstall;
40
54
  const depsInstallError = () => (0, exports.log)(chalk_1.default.red('Error installing NEAR project dependencies'));
41
- exports.show = {
42
- welcome, setupFailed, setupSuccess, argsError,
43
- unsupportedNodeVersion, directoryExists, creatingApp,
44
- depsInstall, depsInstallError,
45
- };
55
+ exports.depsInstallError = depsInstallError;
46
56
  //# sourceMappingURL=messages.js.map
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildPackageJson = void 0;
4
- function buildPackageJson({ contract, frontend, projectName, supportsSandbox }) {
4
+ function buildPackageJson({ contract, frontend, tests, projectName }) {
5
5
  const result = basePackage({
6
- contract, frontend, projectName, supportsSandbox,
6
+ contract, frontend, tests, projectName,
7
7
  });
8
8
  return result;
9
9
  }
10
10
  exports.buildPackageJson = buildPackageJson;
11
- function basePackage({ contract, frontend, projectName, supportsSandbox }) {
11
+ function basePackage({ contract, frontend, tests, projectName }) {
12
12
  const hasFrontend = frontend !== 'none';
13
13
  return {
14
14
  'name': projectName,
@@ -19,35 +19,35 @@ function basePackage({ contract, frontend, projectName, supportsSandbox }) {
19
19
  ...deployScript(contract),
20
20
  ...buildScript(hasFrontend),
21
21
  ...buildContractScript(contract),
22
- 'test': 'yarn test:unit && yarn test:integration',
22
+ 'test': 'npm run test:unit && npm run test:integration',
23
23
  ...unitTestScripts(contract),
24
- ...integrationTestScripts(contract, supportsSandbox),
25
- ...npmInstallScript(contract, supportsSandbox, hasFrontend),
24
+ ...integrationTestScripts(contract, tests),
25
+ ...npmInstallScript(contract, hasFrontend, tests),
26
26
  },
27
27
  'devDependencies': {
28
- 'near-cli': '3.3.0',
28
+ 'near-cli': '^3.3.0',
29
29
  },
30
30
  'dependencies': {}
31
31
  };
32
32
  }
33
33
  const startScript = (hasFrontend) => hasFrontend ? {
34
- 'start': 'cd frontend && yarn start'
34
+ 'start': 'cd frontend && npm run start'
35
35
  } : {};
36
36
  const buildScript = (hasFrontend) => hasFrontend ? {
37
- 'build': 'yarn build:contract && yarn build:web',
38
- 'build:web': 'cd frontend && yarn build',
37
+ 'build': 'npm run build:contract && npm run build:web',
38
+ 'build:web': 'cd frontend && npm run build',
39
39
  } : {
40
- 'build': 'yarn build:contract',
40
+ 'build': 'npm run build:contract',
41
41
  };
42
42
  const buildContractScript = (contract) => {
43
43
  switch (contract) {
44
44
  case 'assemblyscript':
45
45
  return {
46
- 'build:contract': 'cd contract && yarn build',
46
+ 'build:contract': 'cd contract && npm run build',
47
47
  };
48
48
  case 'js':
49
49
  return {
50
- 'build:contract': 'cd contract && yarn build',
50
+ 'build:contract': 'cd contract && npm run build',
51
51
  };
52
52
  case 'rust':
53
53
  return {
@@ -62,11 +62,11 @@ const deployScript = (contract) => {
62
62
  case 'assemblyscript':
63
63
  case 'js':
64
64
  return {
65
- 'deploy': 'cd contract && yarn deploy',
65
+ 'deploy': 'cd contract && npm run deploy',
66
66
  };
67
67
  case 'rust':
68
68
  return {
69
- 'deploy': 'yarn build:contract && cd contract && near dev-deploy --wasmFile ./target/wasm32-unknown-unknown/release/hello_near.wasm',
69
+ 'deploy': 'npm run build:contract && cd contract && near dev-deploy --wasmFile ./target/wasm32-unknown-unknown/release/hello_near.wasm',
70
70
  };
71
71
  default:
72
72
  return {};
@@ -76,63 +76,87 @@ const unitTestScripts = (contract) => {
76
76
  switch (contract) {
77
77
  case 'js':
78
78
  case 'assemblyscript':
79
- return { 'test:unit': 'cd contract && yarn test' };
79
+ return { 'test:unit': 'cd contract && npm test' };
80
80
  case 'rust':
81
81
  return { 'test:unit': 'cd contract && cargo test' };
82
82
  default:
83
83
  return {};
84
84
  }
85
85
  };
86
- const integrationTestScripts = (contract, supportsSandbox) => {
87
- if (supportsSandbox) {
88
- switch (contract) {
89
- case 'assemblyscript':
86
+ const integrationTestScripts = (contract, tests) => {
87
+ switch (contract) {
88
+ case 'assemblyscript':
89
+ if (tests === 'js') {
90
90
  return {
91
- 'test:integration': 'yarn build:contract && cd integration-tests && yarn test -- -- "./contract/build/release/hello_near.wasm"',
91
+ 'test:integration': 'npm run build:contract && cd integration-tests && npm test -- -- "./contract/build/release/hello_near.wasm"',
92
92
  };
93
- case 'js':
93
+ }
94
+ else {
94
95
  return {
95
- 'test:integration': 'yarn build:contract && cd integration-tests && yarn test -- -- "./contract/build/hello_near.wasm"',
96
+ 'test:integration': 'npm run build:contract && cd integration-tests && cargo run --example integration-tests "../contract/build/release/hello_near.wasm"',
96
97
  };
97
- case 'rust':
98
+ }
99
+ case 'js':
100
+ if (tests === 'js') {
98
101
  return {
99
- 'test:integration': 'yarn build:contract && cd integration-tests && cargo run --example integration-tests "../contract/target/wasm32-unknown-unknown/release/hello_near.wasm"',
102
+ 'test:integration': 'npm run build:contract && cd integration-tests && npm test -- -- "./contract/build/hello_near.wasm" "js"',
100
103
  };
101
- default:
102
- return {};
103
- }
104
- }
105
- else {
106
- return {
107
- 'test:integration': 'yarn deploy && cd integration-tests && yarn test',
108
- };
104
+ }
105
+ else {
106
+ return {
107
+ 'test:integration': 'npm run build:contract && cd integration-tests && cargo run --example integration-tests "../contract/build/hello_near.wasm"',
108
+ };
109
+ }
110
+ case 'rust':
111
+ if (tests === 'js') {
112
+ return {
113
+ 'test:integration': 'npm run build:contract && cd integration-tests && npm test -- -- "./contract/target/wasm32-unknown-unknown/release/hello_near.wasm"',
114
+ };
115
+ }
116
+ else {
117
+ return {
118
+ 'test:integration': 'npm run build:contract && cd integration-tests && cargo run --example integration-tests "../contract/target/wasm32-unknown-unknown/release/hello_near.wasm"',
119
+ };
120
+ }
121
+ default:
122
+ return {};
109
123
  }
110
124
  };
111
- const npmInstallScript = (contract, supportsSandbox, hasFrontend) => {
125
+ const npmInstallScript = (contract, hasFrontend, tests) => {
112
126
  switch (contract) {
113
127
  case 'assemblyscript':
114
128
  case 'js':
115
129
  if (hasFrontend) {
116
- return { 'deps-install': 'yarn && cd contract && yarn && cd ../integration-tests && yarn && cd ../frontend && yarn && cd ..' };
130
+ if (tests === 'js') {
131
+ return { 'deps-install': 'npm install && cd contract && npm install && cd ../integration-tests && npm install && cd ../frontend && npm install && cd ..' };
132
+ }
133
+ else {
134
+ return { 'deps-install': 'npm install && cd contract && npm install && cd ../frontend && npm install && cd ..' };
135
+ }
117
136
  }
118
137
  else {
119
- return { 'deps-install': 'yarn && cd contract && yarn && cd ../integration-tests && yarn && cd ..' };
138
+ if (tests === 'js') {
139
+ return { 'deps-install': 'npm install && cd contract && npm install && cd ../integration-tests && npm install && cd ..' };
140
+ }
141
+ else {
142
+ return { 'deps-install': 'npm install && cd contract && npm install && cd ..' };
143
+ }
120
144
  }
121
145
  case 'rust':
122
- if (supportsSandbox) {
123
- if (hasFrontend) {
124
- return { 'deps-install': 'yarn && cd frontend && yarn && cd ..' };
146
+ if (hasFrontend) {
147
+ if (tests === 'js') {
148
+ return { 'deps-install': 'npm install && cd frontend && npm install && cd ../integration-tests && npm install && cd ..' };
125
149
  }
126
150
  else {
127
- return { 'deps-install': 'yarn' };
151
+ return { 'deps-install': 'npm install && cd frontend && npm install && cd ..' };
128
152
  }
129
153
  }
130
154
  else {
131
- if (hasFrontend) {
132
- return { 'deps-install': 'yarn && cd integration-tests && yarn && cd ../frontend && yarn && cd ..' };
155
+ if (tests === 'js') {
156
+ return { 'deps-install': 'npm install && cd ./integration-tests && npm install && cd ..' };
133
157
  }
134
158
  else {
135
- return { 'deps-install': 'yarn && cd integration-tests && yarn && cd ..' };
159
+ return { 'deps-install': 'npm install' };
136
160
  }
137
161
  }
138
162
  }