@dainprotocol/cli 1.0.23 → 1.0.27
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/commands/init.js +24 -81
- package/dist/templates/default/dain.json +1 -1
- package/dist/templates/default/package.json +4 -2
- package/dist/templates/default/src/index.ts +6 -4
- package/package.json +2 -2
- package/templates/default/dain.json +1 -1
- package/templates/default/package.json +4 -2
- package/templates/default/src/index.ts +6 -4
package/dist/commands/init.js
CHANGED
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
@@ -45,49 +9,28 @@ var path_1 = __importDefault(require("path"));
|
|
|
45
9
|
var utils_1 = require("../utils");
|
|
46
10
|
var ora_1 = __importDefault(require("ora"));
|
|
47
11
|
function init(projectName) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
packageJson = _a.sent();
|
|
73
|
-
packageJson.name = projectName;
|
|
74
|
-
return [4 /*yield*/, fs_extra_1.default.writeJson(packageJsonPath, packageJson, { spaces: 2 })];
|
|
75
|
-
case 5:
|
|
76
|
-
_a.sent();
|
|
77
|
-
spinner.succeed("Initialized Dain project: ".concat(projectName));
|
|
78
|
-
(0, utils_1.logSuccess)("Project created at ".concat(projectDir));
|
|
79
|
-
(0, utils_1.logInfo)('Run the following commands to get started:');
|
|
80
|
-
(0, utils_1.logInfo)(" cd ".concat(projectName));
|
|
81
|
-
(0, utils_1.logInfo)(' npm install');
|
|
82
|
-
(0, utils_1.logInfo)(' dain dev');
|
|
83
|
-
return [3 /*break*/, 7];
|
|
84
|
-
case 6:
|
|
85
|
-
error_1 = _a.sent();
|
|
86
|
-
spinner.fail('Project initialization failed');
|
|
87
|
-
(0, utils_1.logError)('Error initializing project', error_1);
|
|
88
|
-
return [3 /*break*/, 7];
|
|
89
|
-
case 7: return [2 /*return*/];
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
});
|
|
12
|
+
var spinner = (0, ora_1.default)('Initializing Dain project...').start();
|
|
13
|
+
var projectDir = path_1.default.join(process.cwd(), projectName);
|
|
14
|
+
var templateDir = path_1.default.join(__dirname, '..', '..', 'templates', 'default');
|
|
15
|
+
try {
|
|
16
|
+
// Create project directory
|
|
17
|
+
fs_extra_1.default.ensureDirSync(projectDir);
|
|
18
|
+
// Copy template files
|
|
19
|
+
fs_extra_1.default.copySync(templateDir, projectDir);
|
|
20
|
+
// Modify package.json
|
|
21
|
+
var packageJsonPath = path_1.default.join(projectDir, 'package.json');
|
|
22
|
+
var packageJson = fs_extra_1.default.readJsonSync(packageJsonPath);
|
|
23
|
+
packageJson.name = projectName;
|
|
24
|
+
fs_extra_1.default.writeJsonSync(packageJsonPath, packageJson, { spaces: 2 });
|
|
25
|
+
spinner.succeed("Initialized Dain project: ".concat(projectName));
|
|
26
|
+
(0, utils_1.logSuccess)("Project created at ".concat(projectDir));
|
|
27
|
+
(0, utils_1.logInfo)('Run the following commands to get started:');
|
|
28
|
+
(0, utils_1.logInfo)(" cd ".concat(projectName));
|
|
29
|
+
(0, utils_1.logInfo)(' npm install');
|
|
30
|
+
(0, utils_1.logInfo)(' dain dev');
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
spinner.fail('Project initialization failed');
|
|
34
|
+
(0, utils_1.logError)('Error initializing project', error);
|
|
35
|
+
}
|
|
93
36
|
}
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
"deploy": "dain deploy"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dainprotocol/service-sdk": "^1.0.
|
|
14
|
-
"zod": "^3.23.8"
|
|
13
|
+
"@dainprotocol/service-sdk": "^1.0.27",
|
|
14
|
+
"zod": "^3.23.8",
|
|
15
|
+
"hono": "^4.6.3"
|
|
16
|
+
|
|
15
17
|
},
|
|
16
18
|
"devDependencies": {
|
|
17
19
|
"@types/express": "^4.17.13",
|
|
@@ -183,7 +183,7 @@ const dainService = defineDAINService({
|
|
|
183
183
|
},
|
|
184
184
|
identity: {
|
|
185
185
|
apiKey:
|
|
186
|
-
|
|
186
|
+
process.env.DAIN_API_KEY,
|
|
187
187
|
},
|
|
188
188
|
services: [weatherServiceConfig],
|
|
189
189
|
tools: [
|
|
@@ -193,8 +193,10 @@ const dainService = defineDAINService({
|
|
|
193
193
|
getHistoricalWeatherConfig,
|
|
194
194
|
],
|
|
195
195
|
toolboxes: [weatherToolboxConfig],
|
|
196
|
+
contexts: []
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
dainService.startNode({ port: 2022 }).then(() => {
|
|
200
|
+
console.log("Comprehensive Weather DAIN Service is running on port 2022");
|
|
196
201
|
});
|
|
197
202
|
|
|
198
|
-
export default {
|
|
199
|
-
fetch: dainService.startWorkers(),
|
|
200
|
-
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dainprotocol/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.27",
|
|
4
4
|
"description": "CLI for Dain Protocol",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@ai-sdk/anthropic": "^0.0.50",
|
|
19
|
-
"@dainprotocol/service-sdk": "^1.0.
|
|
19
|
+
"@dainprotocol/service-sdk": "^1.0.20",
|
|
20
20
|
"@dainprotocol/tunnel": "^1.0.2",
|
|
21
21
|
"@types/fs-extra": "^11.0.4",
|
|
22
22
|
"@types/localtunnel": "^2.0.4",
|
|
@@ -10,8 +10,10 @@
|
|
|
10
10
|
"deploy": "dain deploy"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dainprotocol/service-sdk": "^1.0.
|
|
14
|
-
"zod": "^3.23.8"
|
|
13
|
+
"@dainprotocol/service-sdk": "^1.0.27",
|
|
14
|
+
"zod": "^3.23.8",
|
|
15
|
+
"hono": "^4.6.3"
|
|
16
|
+
|
|
15
17
|
},
|
|
16
18
|
"devDependencies": {
|
|
17
19
|
"@types/express": "^4.17.13",
|
|
@@ -183,7 +183,7 @@ const dainService = defineDAINService({
|
|
|
183
183
|
},
|
|
184
184
|
identity: {
|
|
185
185
|
apiKey:
|
|
186
|
-
|
|
186
|
+
process.env.DAIN_API_KEY,
|
|
187
187
|
},
|
|
188
188
|
services: [weatherServiceConfig],
|
|
189
189
|
tools: [
|
|
@@ -193,8 +193,10 @@ const dainService = defineDAINService({
|
|
|
193
193
|
getHistoricalWeatherConfig,
|
|
194
194
|
],
|
|
195
195
|
toolboxes: [weatherToolboxConfig],
|
|
196
|
+
contexts: []
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
dainService.startNode({ port: 2022 }).then(() => {
|
|
200
|
+
console.log("Comprehensive Weather DAIN Service is running on port 2022");
|
|
196
201
|
});
|
|
197
202
|
|
|
198
|
-
export default {
|
|
199
|
-
fetch: dainService.startWorkers(),
|
|
200
|
-
};
|