@airmoney-degn/airmoney-cli 0.15.0 → 0.16.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/dist/cli/create.js +25 -19
- package/dist/cli/demo.js +66 -0
- package/dist/config.json +1 -1
- package/dist/index.js +13 -3
- package/package.json +1 -1
package/dist/cli/create.js
CHANGED
|
@@ -45,17 +45,21 @@ const child_process_1 = require("child_process");
|
|
|
45
45
|
* process.env.DEVELOPER_ADDRESS
|
|
46
46
|
* process.env.API_KEY
|
|
47
47
|
*/
|
|
48
|
-
async function createCommand(name,
|
|
48
|
+
async function createCommand(name, template, locationFolder, quiet, ignoreEnvValidation) {
|
|
49
49
|
// read from env (the .env was placed in config by `setup`).
|
|
50
50
|
const userId = process.env.DEVELOPER_ADDRESS || '';
|
|
51
51
|
const apiKey = process.env.API_KEY || '';
|
|
52
|
-
if (!
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
if (!ignoreEnvValidation) {
|
|
53
|
+
if (!userId || !apiKey) {
|
|
54
|
+
console.error("Missing user or API key from env. Did you run 'airmoney-cli setup'?");
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
55
57
|
}
|
|
56
58
|
const identifier = `com.degn.${name}`;
|
|
57
|
-
console.log(`Initializing project: ${name}
|
|
58
|
-
|
|
59
|
+
console.log(`Initializing project: ${name}`);
|
|
60
|
+
if (!ignoreEnvValidation) {
|
|
61
|
+
console.log(`Using .env user: ${userId}`);
|
|
62
|
+
}
|
|
59
63
|
const folderName = locationFolder || name;
|
|
60
64
|
const projectPath = path.join(process.cwd(), folderName);
|
|
61
65
|
if (template) {
|
|
@@ -93,18 +97,20 @@ async function createCommand(name, network, template, locationFolder) {
|
|
|
93
97
|
const metaStr = JSON.stringify(pkg, null, 2);
|
|
94
98
|
fs.writeFileSync(path.join(projectPath, 'metadata.json'), metaStr, 'utf8');
|
|
95
99
|
console.log(`Project '${name}' created successfully.`);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
if (!quiet) {
|
|
101
|
+
console.log(`\nNext steps:`);
|
|
102
|
+
console.log(` cd ${name}`);
|
|
103
|
+
if (template) {
|
|
104
|
+
console.log(' npm install');
|
|
105
|
+
console.log('\n- Development mode:');
|
|
106
|
+
console.log(' npm run dev');
|
|
107
|
+
console.log(' airmoney-cli serve -u http://localhost:5173');
|
|
108
|
+
console.log('\n- Production build:');
|
|
109
|
+
console.log(' npm run build');
|
|
110
|
+
console.log(' airmoney-cli serve -f dist');
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
console.log(' airmoney-cli serve');
|
|
114
|
+
}
|
|
109
115
|
}
|
|
110
116
|
}
|
package/dist/cli/demo.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
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)(projectName, true, appPath, true, true);
|
|
46
|
+
try {
|
|
47
|
+
console.log('Installing dependencies...');
|
|
48
|
+
(0, child_process_1.execSync)('npm install', { cwd: projectPath, stdio: 'inherit' });
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
console.error('Failed to install dependencies');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
console.log('Starting dev server...');
|
|
55
|
+
const devProc = (0, child_process_1.spawn)('npm', ['run', 'dev'], {
|
|
56
|
+
cwd: projectPath,
|
|
57
|
+
stdio: 'inherit',
|
|
58
|
+
shell: process.platform === 'win32',
|
|
59
|
+
});
|
|
60
|
+
devProc.on('error', err => {
|
|
61
|
+
console.error('Failed to start dev server:', err);
|
|
62
|
+
});
|
|
63
|
+
// Give the dev server a moment to boot; default Vite port is 5173
|
|
64
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
65
|
+
await (0, serve_1.serveCommand)(false, undefined, 'http://localhost:5173');
|
|
66
|
+
}
|
package/dist/config.json
CHANGED
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");
|
|
@@ -30,12 +31,12 @@ 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,
|
|
38
|
-
await (0, create_1.createCommand)(name,
|
|
38
|
+
const { name, appPath, template } = opts;
|
|
39
|
+
await (0, create_1.createCommand)(name, template, appPath);
|
|
39
40
|
});
|
|
40
41
|
program
|
|
41
42
|
.command('serve')
|
|
@@ -103,5 +104,14 @@ program
|
|
|
103
104
|
// user and key are read from store config within uploadCommand
|
|
104
105
|
await (0, upload_1.uploadCommand)(network, indexAppPath, buttonImage);
|
|
105
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);
|
|
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.
|
|
3
|
+
"version": "0.16.0",
|
|
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"
|