Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cli 2 #280

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@meshsdk/root",
"private": true,
"scripts": {
"build": "npm run build:mesh && npm run build:docs && npm run build:apps && npm run build:scripts",
"build": "turbo build --concurrency 15",
"build:apps": "turbo run build:apps",
"build:docs": "turbo run build:docs",
"build:mesh": "turbo run build:mesh",
Expand Down
2 changes: 0 additions & 2 deletions scripts/mesh-cli/bin/create-mesh-app

This file was deleted.

2 changes: 2 additions & 0 deletions scripts/mesh-cli/bin/meshjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#! /usr/bin/env node
require('../dist/index.js');
11 changes: 8 additions & 3 deletions scripts/mesh-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"description": "A quick and easy way to bootstrap your dApps on Cardano using Mesh.",
"homepage": "https://meshjs.dev",
"author": "MeshJS",
"version": "1.5.3",
"version": "1.5.4",
"license": "Apache-2.0",
"main": "dist/meshjs.cjs.js",
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"bin": {
"meshjs": "./bin/meshjs"
},
Expand All @@ -23,7 +25,9 @@
"npx"
],
"scripts": {
"build:scripts": "preconstruct build",
"clean": "rm -rf .turbo && rm -rf dist && rm -rf node_modules",
"build:scripts": "tsup src/index.ts --format esm,cjs --dts",
"build:scripts:old": "preconstruct build",
"start": "preconstruct watch"
},
"dependencies": {
Expand All @@ -37,6 +41,7 @@
"devDependencies": {
"@preconstruct/cli": "2.8.4",
"@types/figlet": "1.5.8",
"@types/got": "^9.6.12",
"@types/prompts": "2.4.9",
"@types/tar": "6.1.13"
}
Expand Down
9 changes: 2 additions & 7 deletions scripts/mesh-cli/src/actions/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,8 @@ export const create = async (name, options) => {
const template =
options.template ??
(await askUser('What template do you want to use?', [
{ title: 'NextJs starter template', value: 'mesh-nextjs' },
// { title: 'Multi-Sig Minting', value: 'minting' },
// { title: 'Stake-Pool Website', value: 'staking' },
// { title: 'Cardano Sign-In', value: 'signin' },
// { title: 'E-Commerce Store', value: 'ecommerce' },
// { title: 'Marketplace', value: 'marketplace' },
{ title: 'Aiken template', value: 'mesh-aiken' },
{ title: "Aiken", value: "mesh-aiken" },
{ title: "NextJS", value: "mesh-nextjs" },
]));

console.log('\n');
Expand Down
51 changes: 27 additions & 24 deletions scripts/mesh-cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,65 +1,68 @@
import chalk from 'chalk';
import figlet from 'figlet';
import chalk from "chalk";
import figlet from "figlet";
import {
createArgument, createCommand,
createOption, InvalidArgumentError,
} from 'commander';
import { create } from './actions';
import { logError, logSuccess } from './utils';
createArgument,
createCommand,
createOption,
InvalidArgumentError,
} from "commander";
import { create } from "./actions";
import { logError, logSuccess } from "./utils";

const main = async () => {
console.clear();

console.info(
chalk.blue(
figlet.textSync('!Create Mesh dApp', {
font: 'Speed', horizontalLayout: 'full',
chalk.blueBright(
figlet.textSync("MeshJS", {
font: "Larry 3D",
horizontalLayout: "full",
})
)
);

console.log('\n');
console.log("\n");

const program = createCommand();

program
.name('create-mesh-app')
.name("meshjs")
.description(
'A quick and easy way to bootstrap your dApps on Cardano using Mesh.'
"A quick and easy way to bootstrap your dApps on Cardano using Mesh."
)
.version('1.0.0');
.version("1.0.0");

program
.addArgument(
createArgument('name', 'Set a name for your dApp.')
createArgument("name", "Set a name for your dApp.")
.argParser((name) => {
if (/^([A-Za-z\-\\_\d])+$/.test(name)) return name;

throw new InvalidArgumentError(
chalk.redBright(
'❗ Only letters, numbers, underscores and, hashes are allowed.',
),
"❗ Only letters, numbers, underscores and, hashes are allowed."
)
);
})
.argRequired()
)
.addOption(
createOption(
'-t, --template <TEMPLATE-NAME>',
"-t, --template <TEMPLATE-NAME>",
`The template to start your project from.`
).choices(['starter', 'minting', 'staking', 'ecommerce', 'signin', 'marketplace'])
).choices(["nextjs", "aiken"])
)
.addOption(
createOption(
'-s, --stack <STACK-NAME>',
"-s, --stack <STACK-NAME>",
`The tech stack you want to build on.`
).choices(['next'])
).choices(["next"])
)
.addOption(
createOption(
'-l, --language <LANGUAGE-NAME>',
"-l, --language <LANGUAGE-NAME>",
`The language you want to use.`
).choices(['ts'])
).choices(["ts"])
)
.action(create);

Expand All @@ -68,7 +71,7 @@ const main = async () => {

main()
.then(() => {
logSuccess('✨✨ Welcome to Web 3.0! ✨✨');
logSuccess("✨✨ Welcome to Web 3.0! ✨✨");
process.exit(0);
})
.catch((error) => {
Expand Down