meshjs 1.5.3 → 1.5.5

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/bin/meshjs ADDED
@@ -0,0 +1,2 @@
1
+ #! /usr/bin/env node
2
+ import('../dist/index.js');
package/package.json CHANGED
@@ -3,9 +3,11 @@
3
3
  "description": "A quick and easy way to bootstrap your dApps on Cardano using Mesh.",
4
4
  "homepage": "https://meshjs.dev",
5
5
  "author": "MeshJS",
6
- "version": "1.5.3",
6
+ "version": "1.5.5",
7
7
  "license": "Apache-2.0",
8
- "main": "dist/meshjs.cjs.js",
8
+ "type": "module",
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.js",
9
11
  "bin": {
10
12
  "meshjs": "./bin/meshjs"
11
13
  },
@@ -23,7 +25,9 @@
23
25
  "npx"
24
26
  ],
25
27
  "scripts": {
26
- "build:scripts": "preconstruct build",
28
+ "clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
29
+ "build:scripts": "tsup src/index.ts --format esm,cjs --dts",
30
+ "build:scripts:old": "preconstruct build",
27
31
  "start": "preconstruct watch"
28
32
  },
29
33
  "dependencies": {
@@ -37,6 +41,7 @@
37
41
  "devDependencies": {
38
42
  "@preconstruct/cli": "2.8.4",
39
43
  "@types/figlet": "1.5.8",
44
+ "@types/got": "^9.6.12",
40
45
  "@types/prompts": "2.4.9",
41
46
  "@types/tar": "6.1.13"
42
47
  }
@@ -12,13 +12,8 @@ export const create = async (name, options) => {
12
12
  const template =
13
13
  options.template ??
14
14
  (await askUser('What template do you want to use?', [
15
- { title: 'NextJs starter template', value: 'mesh-nextjs' },
16
- // { title: 'Multi-Sig Minting', value: 'minting' },
17
- // { title: 'Stake-Pool Website', value: 'staking' },
18
- // { title: 'Cardano Sign-In', value: 'signin' },
19
- // { title: 'E-Commerce Store', value: 'ecommerce' },
20
- // { title: 'Marketplace', value: 'marketplace' },
21
- { title: 'Aiken template', value: 'mesh-aiken' },
15
+ { title: "Aiken", value: "mesh-aiken" },
16
+ { title: "NextJS", value: "mesh-nextjs" },
22
17
  ]));
23
18
 
24
19
  console.log('\n');
package/src/index.ts CHANGED
@@ -1,65 +1,68 @@
1
- import chalk from 'chalk';
2
- import figlet from 'figlet';
1
+ import chalk from "chalk";
2
+ import figlet from "figlet";
3
3
  import {
4
- createArgument, createCommand,
5
- createOption, InvalidArgumentError,
6
- } from 'commander';
7
- import { create } from './actions';
8
- import { logError, logSuccess } from './utils';
4
+ createArgument,
5
+ createCommand,
6
+ createOption,
7
+ InvalidArgumentError,
8
+ } from "commander";
9
+ import { create } from "./actions";
10
+ import { logError, logSuccess } from "./utils";
9
11
 
10
12
  const main = async () => {
11
13
  console.clear();
12
14
 
13
15
  console.info(
14
- chalk.blue(
15
- figlet.textSync('!Create Mesh dApp', {
16
- font: 'Speed', horizontalLayout: 'full',
16
+ chalk.blueBright(
17
+ figlet.textSync("MeshJS", {
18
+ font: "Larry 3D",
19
+ horizontalLayout: "full",
17
20
  })
18
21
  )
19
22
  );
20
23
 
21
- console.log('\n');
24
+ console.log("\n");
22
25
 
23
26
  const program = createCommand();
24
27
 
25
28
  program
26
- .name('create-mesh-app')
29
+ .name("meshjs")
27
30
  .description(
28
- 'A quick and easy way to bootstrap your dApps on Cardano using Mesh.'
31
+ "A quick and easy way to bootstrap your dApps on Cardano using Mesh."
29
32
  )
30
- .version('1.0.0');
33
+ .version("1.0.0");
31
34
 
32
35
  program
33
36
  .addArgument(
34
- createArgument('name', 'Set a name for your dApp.')
37
+ createArgument("name", "Set a name for your dApp.")
35
38
  .argParser((name) => {
36
39
  if (/^([A-Za-z\-\\_\d])+$/.test(name)) return name;
37
40
 
38
41
  throw new InvalidArgumentError(
39
42
  chalk.redBright(
40
- '❗ Only letters, numbers, underscores and, hashes are allowed.',
41
- ),
43
+ "❗ Only letters, numbers, underscores and, hashes are allowed."
44
+ )
42
45
  );
43
46
  })
44
47
  .argRequired()
45
48
  )
46
49
  .addOption(
47
50
  createOption(
48
- '-t, --template <TEMPLATE-NAME>',
51
+ "-t, --template <TEMPLATE-NAME>",
49
52
  `The template to start your project from.`
50
- ).choices(['starter', 'minting', 'staking', 'ecommerce', 'signin', 'marketplace'])
53
+ ).choices(["nextjs", "aiken"])
51
54
  )
52
55
  .addOption(
53
56
  createOption(
54
- '-s, --stack <STACK-NAME>',
57
+ "-s, --stack <STACK-NAME>",
55
58
  `The tech stack you want to build on.`
56
- ).choices(['next'])
59
+ ).choices(["next"])
57
60
  )
58
61
  .addOption(
59
62
  createOption(
60
- '-l, --language <LANGUAGE-NAME>',
63
+ "-l, --language <LANGUAGE-NAME>",
61
64
  `The language you want to use.`
62
- ).choices(['ts'])
65
+ ).choices(["ts"])
63
66
  )
64
67
  .action(create);
65
68
 
@@ -68,7 +71,7 @@ const main = async () => {
68
71
 
69
72
  main()
70
73
  .then(() => {
71
- logSuccess('✨✨ Welcome to Web 3.0! ✨✨');
74
+ logSuccess("✨✨ Welcome to Web 3.0! ✨✨");
72
75
  process.exit(0);
73
76
  })
74
77
  .catch((error) => {
@@ -1,2 +0,0 @@
1
- #! /usr/bin/env node
2
- require('../dist/create-mesh-app.cjs.js');
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export * from "./declarations/src/index";
2
- //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVzaGpzLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi9kZWNsYXJhdGlvbnMvc3JjL2luZGV4LmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
@@ -1,214 +0,0 @@
1
- 'use strict';
2
-
3
- var chalk = require('chalk');
4
- var figlet = require('figlet');
5
- var commander = require('commander');
6
- var got = require('got');
7
- var prompts = require('prompts');
8
- var tar = require('tar');
9
- var util = require('util');
10
- var stream = require('stream');
11
- var fs = require('fs');
12
- var child_process = require('child_process');
13
- var os = require('os');
14
- var path = require('path');
15
-
16
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
17
-
18
- var chalk__default = /*#__PURE__*/_interopDefault(chalk);
19
- var figlet__default = /*#__PURE__*/_interopDefault(figlet);
20
- var got__default = /*#__PURE__*/_interopDefault(got);
21
- var prompts__default = /*#__PURE__*/_interopDefault(prompts);
22
-
23
- const resolvePkgManager = () => {
24
- try {
25
- const userAgent = process.env.npm_config_user_agent;
26
- if (userAgent?.startsWith('yarn')) {
27
- return 'yarn';
28
- }
29
- if (userAgent?.startsWith('pnpm')) {
30
- return 'pnpm';
31
- }
32
- try {
33
- child_process.execSync('yarn --version', {
34
- stdio: 'ignore'
35
- });
36
- return 'yarn';
37
- } catch (_) {
38
- child_process.execSync('pnpm --version', {
39
- stdio: 'ignore'
40
- });
41
- return 'pnpm';
42
- }
43
- } catch (_) {
44
- return 'npm';
45
- }
46
- };
47
-
48
- const setProjectName = (path$1, name) => {
49
- const packagePath = path.join(path$1, 'package.json');
50
- const packageContent = fs.readFileSync(packagePath);
51
- const packageJson = JSON.parse(packageContent.toString());
52
- if (packageJson) {
53
- packageJson.name = name;
54
- }
55
- fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2) + os.EOL);
56
- };
57
-
58
- const tryGitInit = () => {
59
- try {
60
- child_process.execSync('git --version', {
61
- stdio: 'ignore'
62
- });
63
- if (isInGitRepository() || isInMercurialRepository()) {
64
- return false;
65
- }
66
- child_process.execSync('git init', {
67
- stdio: 'ignore'
68
- });
69
- child_process.execSync('git checkout -b main', {
70
- stdio: 'ignore'
71
- });
72
- child_process.execSync('git add -A', {
73
- stdio: 'ignore'
74
- });
75
- child_process.execSync('git commit -m "Initial commit from npx mesh-create-dapp"', {
76
- stdio: 'ignore'
77
- });
78
- return true;
79
- } catch (_) {
80
- return false;
81
- }
82
- };
83
- const isInGitRepository = () => {
84
- try {
85
- child_process.execSync('git rev-parse --is-inside-work-tree', {
86
- stdio: 'ignore'
87
- });
88
- return true;
89
- } catch (_) {}
90
- return false;
91
- };
92
- const isInMercurialRepository = () => {
93
- try {
94
- child_process.execSync('hg --cwd . root', {
95
- stdio: 'ignore'
96
- });
97
- return true;
98
- } catch (_) {}
99
- return false;
100
- };
101
-
102
- const logError = message => {
103
- console.log(chalk__default["default"].redBright(message + '\n'));
104
- };
105
- const logSuccess = message => {
106
- console.log(chalk__default["default"].greenBright(message + '\n'));
107
- };
108
- const logInfo = message => {
109
- console.log(chalk__default["default"].blueBright(message + '\n'));
110
- };
111
-
112
- const create = async (name, options) => {
113
- const template = options.template ?? (await askUser('What template do you want to use?', [{
114
- title: 'NextJs starter template',
115
- value: 'mesh-nextjs'
116
- },
117
- // { title: 'Multi-Sig Minting', value: 'minting' },
118
- // { title: 'Stake-Pool Website', value: 'staking' },
119
- // { title: 'Cardano Sign-In', value: 'signin' },
120
- // { title: 'E-Commerce Store', value: 'ecommerce' },
121
- // { title: 'Marketplace', value: 'marketplace' },
122
- {
123
- title: 'Aiken template',
124
- value: 'mesh-aiken'
125
- }]));
126
- console.log('\n');
127
- try {
128
- createDirectory(name);
129
- logInfo('📡 - Downloading files..., This might take a moment.');
130
- await fetchRepository(template);
131
- logInfo('🏠 - Starting a new git repository...');
132
- setNameAndCommitChanges(name);
133
- logInfo('🧶 - Installing project dependencies...');
134
- installDependencies();
135
- } catch (error) {
136
- logError(error);
137
- process.exit(1);
138
- }
139
- };
140
- const askUser = async (question, choices) => {
141
- const response = await prompts__default["default"]({
142
- type: 'select',
143
- message: question,
144
- name: 'selection',
145
- choices
146
- }, {
147
- onCancel: () => process.exit(0)
148
- });
149
- return response.selection;
150
- };
151
- const createDirectory = name => {
152
- const path = `${process.cwd()}/${name}`;
153
- if (fs.existsSync(path)) {
154
- logError(`❗ A directory with name: "${name}" already exists.`);
155
- process.exit(1);
156
- }
157
- if (fs.mkdirSync(path, {
158
- recursive: true
159
- }) === undefined) {
160
- logError('❌ Unable to create a project in current directory.');
161
- process.exit(1);
162
- }
163
- logInfo('🏗️ - Creating a new mesh dApp in current directory...');
164
- process.chdir(path);
165
- };
166
- const fetchRepository = async template => {
167
- const pipe = util.promisify(stream.pipeline);
168
- const name = `${template}-template`;
169
- const link = `https://codeload.github.com/MeshJS/${name}/tar.gz/main`;
170
- await pipe(got__default["default"].stream(link), tar.extract({
171
- strip: 1
172
- }, [`${name}-main`]));
173
- };
174
- const setNameAndCommitChanges = name => {
175
- try {
176
- setProjectName(process.cwd(), name);
177
- } catch (_) {
178
- logError('🚫 Failed to re-name package.json, continuing...');
179
- }
180
- tryGitInit();
181
- };
182
- const installDependencies = () => {
183
- try {
184
- const pkgManager = resolvePkgManager();
185
- child_process.execSync(`${pkgManager} install`, {
186
- stdio: [0, 1, 2]
187
- });
188
- } catch (_) {
189
- logError('🚫 Failed to install project dependencies, continuing...');
190
- }
191
- };
192
-
193
- const main = async () => {
194
- console.clear();
195
- console.info(chalk__default["default"].blue(figlet__default["default"].textSync('!Create Mesh dApp', {
196
- font: 'Speed',
197
- horizontalLayout: 'full'
198
- })));
199
- console.log('\n');
200
- const program = commander.createCommand();
201
- program.name('create-mesh-app').description('A quick and easy way to bootstrap your dApps on Cardano using Mesh.').version('1.0.0');
202
- program.addArgument(commander.createArgument('name', 'Set a name for your dApp.').argParser(name => {
203
- if (/^([A-Za-z\-\\_\d])+$/.test(name)) return name;
204
- throw new commander.InvalidArgumentError(chalk__default["default"].redBright('❗ Only letters, numbers, underscores and, hashes are allowed.'));
205
- }).argRequired()).addOption(commander.createOption('-t, --template <TEMPLATE-NAME>', `The template to start your project from.`).choices(['starter', 'minting', 'staking', 'ecommerce', 'signin', 'marketplace'])).addOption(commander.createOption('-s, --stack <STACK-NAME>', `The tech stack you want to build on.`).choices(['next'])).addOption(commander.createOption('-l, --language <LANGUAGE-NAME>', `The language you want to use.`).choices(['ts'])).action(create);
206
- await program.parseAsync(process.argv);
207
- };
208
- main().then(() => {
209
- logSuccess('✨✨ Welcome to Web 3.0! ✨✨');
210
- process.exit(0);
211
- }).catch(error => {
212
- logError(error);
213
- process.exit(1);
214
- });
@@ -1,7 +0,0 @@
1
- 'use strict';
2
-
3
- if (process.env.NODE_ENV === "production") {
4
- module.exports = require("./meshjs.cjs.prod.js");
5
- } else {
6
- module.exports = require("./meshjs.cjs.dev.js");
7
- }
@@ -1,214 +0,0 @@
1
- 'use strict';
2
-
3
- var chalk = require('chalk');
4
- var figlet = require('figlet');
5
- var commander = require('commander');
6
- var got = require('got');
7
- var prompts = require('prompts');
8
- var tar = require('tar');
9
- var util = require('util');
10
- var stream = require('stream');
11
- var fs = require('fs');
12
- var child_process = require('child_process');
13
- var os = require('os');
14
- var path = require('path');
15
-
16
- function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
17
-
18
- var chalk__default = /*#__PURE__*/_interopDefault(chalk);
19
- var figlet__default = /*#__PURE__*/_interopDefault(figlet);
20
- var got__default = /*#__PURE__*/_interopDefault(got);
21
- var prompts__default = /*#__PURE__*/_interopDefault(prompts);
22
-
23
- const resolvePkgManager = () => {
24
- try {
25
- const userAgent = process.env.npm_config_user_agent;
26
- if (userAgent?.startsWith('yarn')) {
27
- return 'yarn';
28
- }
29
- if (userAgent?.startsWith('pnpm')) {
30
- return 'pnpm';
31
- }
32
- try {
33
- child_process.execSync('yarn --version', {
34
- stdio: 'ignore'
35
- });
36
- return 'yarn';
37
- } catch (_) {
38
- child_process.execSync('pnpm --version', {
39
- stdio: 'ignore'
40
- });
41
- return 'pnpm';
42
- }
43
- } catch (_) {
44
- return 'npm';
45
- }
46
- };
47
-
48
- const setProjectName = (path$1, name) => {
49
- const packagePath = path.join(path$1, 'package.json');
50
- const packageContent = fs.readFileSync(packagePath);
51
- const packageJson = JSON.parse(packageContent.toString());
52
- if (packageJson) {
53
- packageJson.name = name;
54
- }
55
- fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2) + os.EOL);
56
- };
57
-
58
- const tryGitInit = () => {
59
- try {
60
- child_process.execSync('git --version', {
61
- stdio: 'ignore'
62
- });
63
- if (isInGitRepository() || isInMercurialRepository()) {
64
- return false;
65
- }
66
- child_process.execSync('git init', {
67
- stdio: 'ignore'
68
- });
69
- child_process.execSync('git checkout -b main', {
70
- stdio: 'ignore'
71
- });
72
- child_process.execSync('git add -A', {
73
- stdio: 'ignore'
74
- });
75
- child_process.execSync('git commit -m "Initial commit from npx mesh-create-dapp"', {
76
- stdio: 'ignore'
77
- });
78
- return true;
79
- } catch (_) {
80
- return false;
81
- }
82
- };
83
- const isInGitRepository = () => {
84
- try {
85
- child_process.execSync('git rev-parse --is-inside-work-tree', {
86
- stdio: 'ignore'
87
- });
88
- return true;
89
- } catch (_) {}
90
- return false;
91
- };
92
- const isInMercurialRepository = () => {
93
- try {
94
- child_process.execSync('hg --cwd . root', {
95
- stdio: 'ignore'
96
- });
97
- return true;
98
- } catch (_) {}
99
- return false;
100
- };
101
-
102
- const logError = message => {
103
- console.log(chalk__default["default"].redBright(message + '\n'));
104
- };
105
- const logSuccess = message => {
106
- console.log(chalk__default["default"].greenBright(message + '\n'));
107
- };
108
- const logInfo = message => {
109
- console.log(chalk__default["default"].blueBright(message + '\n'));
110
- };
111
-
112
- const create = async (name, options) => {
113
- const template = options.template ?? (await askUser('What template do you want to use?', [{
114
- title: 'NextJs starter template',
115
- value: 'mesh-nextjs'
116
- },
117
- // { title: 'Multi-Sig Minting', value: 'minting' },
118
- // { title: 'Stake-Pool Website', value: 'staking' },
119
- // { title: 'Cardano Sign-In', value: 'signin' },
120
- // { title: 'E-Commerce Store', value: 'ecommerce' },
121
- // { title: 'Marketplace', value: 'marketplace' },
122
- {
123
- title: 'Aiken template',
124
- value: 'mesh-aiken'
125
- }]));
126
- console.log('\n');
127
- try {
128
- createDirectory(name);
129
- logInfo('📡 - Downloading files..., This might take a moment.');
130
- await fetchRepository(template);
131
- logInfo('🏠 - Starting a new git repository...');
132
- setNameAndCommitChanges(name);
133
- logInfo('🧶 - Installing project dependencies...');
134
- installDependencies();
135
- } catch (error) {
136
- logError(error);
137
- process.exit(1);
138
- }
139
- };
140
- const askUser = async (question, choices) => {
141
- const response = await prompts__default["default"]({
142
- type: 'select',
143
- message: question,
144
- name: 'selection',
145
- choices
146
- }, {
147
- onCancel: () => process.exit(0)
148
- });
149
- return response.selection;
150
- };
151
- const createDirectory = name => {
152
- const path = `${process.cwd()}/${name}`;
153
- if (fs.existsSync(path)) {
154
- logError(`❗ A directory with name: "${name}" already exists.`);
155
- process.exit(1);
156
- }
157
- if (fs.mkdirSync(path, {
158
- recursive: true
159
- }) === undefined) {
160
- logError('❌ Unable to create a project in current directory.');
161
- process.exit(1);
162
- }
163
- logInfo('🏗️ - Creating a new mesh dApp in current directory...');
164
- process.chdir(path);
165
- };
166
- const fetchRepository = async template => {
167
- const pipe = util.promisify(stream.pipeline);
168
- const name = `${template}-template`;
169
- const link = `https://codeload.github.com/MeshJS/${name}/tar.gz/main`;
170
- await pipe(got__default["default"].stream(link), tar.extract({
171
- strip: 1
172
- }, [`${name}-main`]));
173
- };
174
- const setNameAndCommitChanges = name => {
175
- try {
176
- setProjectName(process.cwd(), name);
177
- } catch (_) {
178
- logError('🚫 Failed to re-name package.json, continuing...');
179
- }
180
- tryGitInit();
181
- };
182
- const installDependencies = () => {
183
- try {
184
- const pkgManager = resolvePkgManager();
185
- child_process.execSync(`${pkgManager} install`, {
186
- stdio: [0, 1, 2]
187
- });
188
- } catch (_) {
189
- logError('🚫 Failed to install project dependencies, continuing...');
190
- }
191
- };
192
-
193
- const main = async () => {
194
- console.clear();
195
- console.info(chalk__default["default"].blue(figlet__default["default"].textSync('!Create Mesh dApp', {
196
- font: 'Speed',
197
- horizontalLayout: 'full'
198
- })));
199
- console.log('\n');
200
- const program = commander.createCommand();
201
- program.name('create-mesh-app').description('A quick and easy way to bootstrap your dApps on Cardano using Mesh.').version('1.0.0');
202
- program.addArgument(commander.createArgument('name', 'Set a name for your dApp.').argParser(name => {
203
- if (/^([A-Za-z\-\\_\d])+$/.test(name)) return name;
204
- throw new commander.InvalidArgumentError(chalk__default["default"].redBright('❗ Only letters, numbers, underscores and, hashes are allowed.'));
205
- }).argRequired()).addOption(commander.createOption('-t, --template <TEMPLATE-NAME>', `The template to start your project from.`).choices(['starter', 'minting', 'staking', 'ecommerce', 'signin', 'marketplace'])).addOption(commander.createOption('-s, --stack <STACK-NAME>', `The tech stack you want to build on.`).choices(['next'])).addOption(commander.createOption('-l, --language <LANGUAGE-NAME>', `The language you want to use.`).choices(['ts'])).action(create);
206
- await program.parseAsync(process.argv);
207
- };
208
- main().then(() => {
209
- logSuccess('✨✨ Welcome to Web 3.0! ✨✨');
210
- process.exit(0);
211
- }).catch(error => {
212
- logError(error);
213
- process.exit(1);
214
- });