@airmoney-degn/airmoney-cli 0.19.4 → 0.19.6

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.
@@ -36,6 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.createCommand = createCommand;
37
37
  const fs = __importStar(require("fs"));
38
38
  const path = __importStar(require("path"));
39
+ const os = __importStar(require("os"));
39
40
  const types_1 = require("../types");
40
41
  const child_process_1 = require("child_process");
41
42
  const LogService_1 = require("../service/log/LogService");
@@ -47,12 +48,26 @@ async function createCommand({ name, template, locationFolder, quiet, }) {
47
48
  const projectPath = path.join(process.cwd(), folderName);
48
49
  if (template) {
49
50
  (0, LogService_1.log)('cloning project').white();
50
- (0, child_process_1.execSync)(`git clone --separate-git-dir=$(mktemp -u) https://github.com/airmoney-degn/airmoney-dapp-quickstart ${folderName}`);
51
- if (fs.lstatSync(path.join(projectPath, '.git')).isDirectory()) {
52
- fs.rmdirSync(path.join(projectPath, '.git'));
51
+ const tempGitDir = path.join(os.tmpdir(), `airmoney-git-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`);
52
+ // Clean up if it already exists (shouldn't happen, but just in case)
53
+ if (fs.existsSync(tempGitDir)) {
54
+ fs.rmSync(tempGitDir, { recursive: true, force: true });
53
55
  }
54
- else {
55
- fs.rmSync(path.join(projectPath, '.git'));
56
+ try {
57
+ (0, child_process_1.execSync)(`git clone --separate-git-dir="${tempGitDir}" https://github.com/airmoney-degn/airmoney-dapp-quickstart ${folderName}`);
58
+ if (fs.existsSync(path.join(projectPath, '.git'))) {
59
+ if (fs.lstatSync(path.join(projectPath, '.git')).isDirectory()) {
60
+ fs.rmdirSync(path.join(projectPath, '.git'));
61
+ }
62
+ else {
63
+ fs.rmSync(path.join(projectPath, '.git'));
64
+ }
65
+ }
66
+ }
67
+ finally {
68
+ if (fs.existsSync(tempGitDir)) {
69
+ fs.rmSync(tempGitDir, { recursive: true, force: true });
70
+ }
56
71
  }
57
72
  }
58
73
  else {
package/dist/cli/demo.js CHANGED
@@ -35,22 +35,35 @@ var __importStar = (this && this.__importStar) || (function () {
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.demoCommand = demoCommand;
37
37
  const path = __importStar(require("path"));
38
+ const fs_1 = require("fs");
38
39
  const child_process_1 = require("child_process");
39
40
  const create_1 = require("./create");
40
41
  const serve_1 = require("./serve");
41
42
  const LogService_1 = require("../service/log/LogService");
43
+ function getUniqueFolderName(baseName) {
44
+ let folderName = baseName;
45
+ let counter = 1;
46
+ const basePath = process.cwd();
47
+ while ((0, fs_1.existsSync)(path.join(basePath, folderName))) {
48
+ folderName = `${baseName}-${counter}`;
49
+ counter++;
50
+ }
51
+ return folderName;
52
+ }
42
53
  async function demoCommand({ name = "degn-demo", appPath }) {
43
54
  try {
44
55
  const projectName = name;
45
- const folderName = appPath || projectName;
56
+ const baseFolderName = appPath || projectName;
57
+ const folderName = getUniqueFolderName(baseFolderName);
46
58
  const projectPath = path.join(process.cwd(), folderName);
47
59
  await (0, create_1.createCommand)({
48
60
  name: projectName,
49
61
  template: true,
50
- locationFolder: appPath,
62
+ locationFolder: folderName,
51
63
  quiet: true,
52
64
  // ignoreEnvValidation: true,
53
65
  });
66
+ (0, LogService_1.log)(`Project created successfully in folder: ${folderName}`).green();
54
67
  try {
55
68
  (0, LogService_1.log)('Installing dependencies...').white();
56
69
  (0, child_process_1.execSync)('npm install', { cwd: projectPath, stdio: 'inherit' });
package/dist/config.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "0.19.4"
2
+ "version": "0.19.6"
3
3
  }
@@ -46,10 +46,17 @@ async function loadMetadata(projectPath = '.', appUrl) {
46
46
  if (appUrl) {
47
47
  // Fetch from remote URL
48
48
  const url = (0, remote_1.buildRemoteUrl)(appUrl, 'metadata.json');
49
- const fetchedRaw = await (0, remote_1.fetchRemoteText)(url);
50
- if (fetchedRaw === null) {
51
- (0, LogService_1.log)('Error loading metadata from remote URL').red();
52
- return null;
49
+ let fetchedRaw = null;
50
+ let hasLogged = false;
51
+ while (fetchedRaw === null) {
52
+ fetchedRaw = await (0, remote_1.fetchRemoteText)(url);
53
+ if (fetchedRaw === null) {
54
+ if (!hasLogged) {
55
+ (0, LogService_1.log)(`Wating for ${appUrl.endsWith('/') ? appUrl : appUrl + '/'}metadata.json...`).white();
56
+ hasLogged = true;
57
+ }
58
+ await new Promise(resolve => setTimeout(resolve, 1000));
59
+ }
53
60
  }
54
61
  raw = fetchedRaw;
55
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airmoney-degn/airmoney-cli",
3
- "version": "0.19.4",
3
+ "version": "0.19.6",
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"