@airmoney-degn/airmoney-cli 0.15.0 → 0.16.1

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.
@@ -38,24 +38,21 @@ const fs = __importStar(require("fs"));
38
38
  const path = __importStar(require("path"));
39
39
  const types_1 = require("../types");
40
40
  const child_process_1 = require("child_process");
41
- /**
42
- * Command for creating a new project.
43
- * Now no longer requires userId + apiKey from caller;
44
- * it will read them from environment variables:
45
- * process.env.DEVELOPER_ADDRESS
46
- * process.env.API_KEY
47
- */
48
- async function createCommand(name, network, template, locationFolder) {
41
+ async function createCommand({ name, template, locationFolder, quiet, ignoreEnvValidation, }) {
49
42
  // read from env (the .env was placed in config by `setup`).
50
43
  const userId = process.env.DEVELOPER_ADDRESS || '';
51
44
  const apiKey = process.env.API_KEY || '';
52
- if (!userId || !apiKey) {
53
- console.error("Missing user or API key from env. Did you run 'airmoney-cli setup'?");
54
- process.exit(1);
45
+ if (!ignoreEnvValidation) {
46
+ if (!userId || !apiKey) {
47
+ console.error("Missing user or API key from env. Did you run 'airmoney-cli setup'?");
48
+ process.exit(1);
49
+ }
55
50
  }
56
51
  const identifier = `com.degn.${name}`;
57
- console.log(`Initializing project: ${name} (network=${network})`);
58
- console.log(`Using .env user: ${userId}`);
52
+ console.log(`Initializing project: ${name}`);
53
+ if (!ignoreEnvValidation) {
54
+ console.log(`Using .env user: ${userId}`);
55
+ }
59
56
  const folderName = locationFolder || name;
60
57
  const projectPath = path.join(process.cwd(), folderName);
61
58
  if (template) {
@@ -93,18 +90,20 @@ async function createCommand(name, network, template, locationFolder) {
93
90
  const metaStr = JSON.stringify(pkg, null, 2);
94
91
  fs.writeFileSync(path.join(projectPath, 'metadata.json'), metaStr, 'utf8');
95
92
  console.log(`Project '${name}' created successfully.`);
96
- console.log(`\nNext steps:`);
97
- console.log(` cd ${name}`);
98
- if (template) {
99
- console.log(' npm install');
100
- console.log('\n- Development mode:');
101
- console.log(' npm run dev');
102
- console.log(' airmoney-cli serve -u http://localhost:5173');
103
- console.log('\n- Production build:');
104
- console.log(' npm run build');
105
- console.log(' airmoney-cli serve -f dist');
106
- }
107
- else {
108
- console.log(' airmoney-cli serve');
93
+ if (!quiet) {
94
+ console.log(`\nNext steps:`);
95
+ console.log(` cd ${name}`);
96
+ if (template) {
97
+ console.log(' npm install');
98
+ console.log('\n- Development mode:');
99
+ console.log(' npm run dev');
100
+ console.log(' airmoney-cli serve -u http://localhost:5173');
101
+ console.log('\n- Production build:');
102
+ console.log(' npm run build');
103
+ console.log(' airmoney-cli serve -f dist');
104
+ }
105
+ else {
106
+ console.log(' airmoney-cli serve');
107
+ }
109
108
  }
110
109
  }
@@ -0,0 +1,72 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.demoCommand = demoCommand;
37
+ const path = __importStar(require("path"));
38
+ const child_process_1 = require("child_process");
39
+ const create_1 = require("./create");
40
+ const serve_1 = require("./serve");
41
+ async function demoCommand({ name, appPath }) {
42
+ const projectName = name || 'degn-demo';
43
+ const folderName = appPath || projectName;
44
+ const projectPath = path.join(process.cwd(), folderName);
45
+ await (0, create_1.createCommand)({
46
+ name: projectName,
47
+ template: true,
48
+ locationFolder: appPath,
49
+ quiet: true,
50
+ ignoreEnvValidation: true,
51
+ });
52
+ try {
53
+ console.log('Installing dependencies...');
54
+ (0, child_process_1.execSync)('npm install', { cwd: projectPath, stdio: 'inherit' });
55
+ }
56
+ catch (e) {
57
+ console.error('Failed to install dependencies');
58
+ return;
59
+ }
60
+ console.log('Starting dev server...');
61
+ const devProc = (0, child_process_1.spawn)('npm', ['run', 'dev'], {
62
+ cwd: projectPath,
63
+ stdio: 'inherit',
64
+ shell: process.platform === 'win32',
65
+ });
66
+ devProc.on('error', err => {
67
+ console.error('Failed to start dev server:', err);
68
+ });
69
+ // Give the dev server a moment to boot; default Vite port is 5173
70
+ await new Promise(resolve => setTimeout(resolve, 3000));
71
+ await (0, serve_1.serveCommand)({ noBrowser: false, locationFolder: undefined, appUrl: 'http://localhost:5173' });
72
+ }
package/dist/cli/serve.js CHANGED
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.serveCommand = serveCommand;
4
4
  const ServeOrchestrator_1 = require("../service/serve/ServeOrchestrator");
5
- async function serveCommand(noBrowser, locationFolder, appUrl) {
5
+ async function serveCommand({ noBrowser, locationFolder, appUrl, }) {
6
6
  const orchestrator = new ServeOrchestrator_1.ServeOrchestrator({
7
7
  noBrowser,
8
8
  locationFolder,
package/dist/cli/setup.js CHANGED
@@ -37,7 +37,7 @@ exports.setupCommand = setupCommand;
37
37
  const fs = __importStar(require("fs"));
38
38
  const path = __importStar(require("path"));
39
39
  const env_1 = require("../util/env");
40
- async function setupCommand(network, userId, apiKey) {
40
+ async function setupCommand({ network, userId, apiKey, }) {
41
41
  const dir = (0, env_1.configDir)();
42
42
  if (!dir)
43
43
  return;
@@ -43,11 +43,7 @@ const md5_1 = __importDefault(require("md5")); // default import fixes TS call
43
43
  const metadata_1 = require("../util/metadata");
44
44
  const tarball_1 = require("../util/tarball");
45
45
  const path_1 = __importDefault(require("path"));
46
- /**
47
- * Upload command now reads userId, apiKey from environment or store config,
48
- * ignoring the older CLI inputs.
49
- */
50
- async function uploadCommand(network, locationFolder, buttonImages) {
46
+ async function uploadCommand({ network, locationFolder, buttonImages, }) {
51
47
  console.log('Loading metadata...');
52
48
  const userId = process.env.DEVELOPER_ADDRESS || '';
53
49
  const apiKey = process.env.API_KEY || '';
package/dist/config.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.15.0"
2
+ "version": "0.16.1"
3
3
  }
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
  "use strict";
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const commander_1 = require("commander");
5
+ const demo_1 = require("./cli/demo");
5
6
  const env_1 = require("./util/env");
6
7
  const create_1 = require("./cli/create");
7
8
  const serve_1 = require("./cli/serve");
@@ -24,18 +25,18 @@ program
24
25
  .option('-n, --network <string>', 'network devnet|mainnet', 'devnet')
25
26
  .action(opts => {
26
27
  const { user, key, network } = opts;
27
- (0, setup_1.setupCommand)(network, user, key);
28
+ (0, setup_1.setupCommand)({ network, userId: user, apiKey: key });
28
29
  });
29
30
  program
30
31
  .command('create')
31
32
  .description('Initialize a new project')
32
33
  .requiredOption('-N, --name <string>', 'Project name')
33
- .option('-n, --network <string>', 'network devnet|mainnet', 'devnet')
34
+ // .option('-n, --network <string>', 'network devnet|mainnet', 'devnet')
34
35
  .option('-f, --app-path <string>', 'path where project will be created')
35
36
  .option('--template', 'initialize project based on git quickstart')
36
37
  .action(async (opts) => {
37
- const { name, network, appPath, template } = opts;
38
- await (0, create_1.createCommand)(name, network, template, appPath);
38
+ const { name, appPath, template } = opts;
39
+ await (0, create_1.createCommand)({ name, template, locationFolder: appPath });
39
40
  });
40
41
  program
41
42
  .command('serve')
@@ -52,7 +53,7 @@ program
52
53
  console.error('both --index-app-path and --app-url must not be used simuntaniusly');
53
54
  return;
54
55
  }
55
- await (0, serve_1.serveCommand)(!browser, indexAppPath, appUrl);
56
+ await (0, serve_1.serveCommand)({ noBrowser: !browser, locationFolder: indexAppPath, appUrl });
56
57
  });
57
58
  program
58
59
  .command('wallet')
@@ -101,7 +102,16 @@ program
101
102
  indexAppPath = undefined;
102
103
  }
103
104
  // user and key are read from store config within uploadCommand
104
- await (0, upload_1.uploadCommand)(network, indexAppPath, buttonImage);
105
+ await (0, upload_1.uploadCommand)({ network, locationFolder: indexAppPath, buttonImages: buttonImage });
106
+ });
107
+ program
108
+ .command('demo')
109
+ .option('-N, --name <string>', 'Project name')
110
+ .option('-f, --app-path <string>', 'path where project will be created')
111
+ .description('serve the built-in demo app')
112
+ .action(async (opts) => {
113
+ const { name = 'degn-demo', appPath } = opts;
114
+ await (0, demo_1.demoCommand)({ name, appPath });
105
115
  });
106
116
  program.addHelpText('after', 'for more help access https://dash-devnet.air.fun/');
107
117
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airmoney-degn/airmoney-cli",
3
- "version": "0.15.0",
3
+ "version": "0.16.1",
4
4
  "description": "airmoney-cli is a command-line interface tool designed to facilitate the development and management of decentralized applications (DApps) for Airmoney.",
5
5
  "publishConfig": {
6
6
  "access": "public"