@project-ajax/create 0.0.20 → 0.0.21
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/index.js +4 -29
- package/package.json +1 -1
- package/template/README.md +14 -0
package/dist/index.js
CHANGED
|
@@ -18,38 +18,25 @@ ${err.message}`));
|
|
|
18
18
|
process.exit(1);
|
|
19
19
|
});
|
|
20
20
|
async function run() {
|
|
21
|
-
console.log(chalk.bold.cyan("\n\u{1F680} Create a new
|
|
21
|
+
console.log(chalk.bold.cyan("\n\u{1F680} Create a new worker\n"));
|
|
22
22
|
const { values } = parseArgs({
|
|
23
23
|
options: {
|
|
24
24
|
directory: {
|
|
25
25
|
type: "string",
|
|
26
26
|
short: "d"
|
|
27
|
-
},
|
|
28
|
-
project: {
|
|
29
|
-
type: "string",
|
|
30
|
-
short: "p"
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
});
|
|
34
30
|
let directoryName = values.directory;
|
|
35
|
-
let projectName = values.project;
|
|
36
31
|
if (!directoryName) {
|
|
37
32
|
directoryName = await safePrompt({
|
|
38
33
|
message: "Path to the new worker project:",
|
|
39
34
|
default: ".",
|
|
40
35
|
required: true,
|
|
41
|
-
noTTY: "Provide the path to the new project with --directory"
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
if (!projectName) {
|
|
45
|
-
projectName = await safePrompt({
|
|
46
|
-
message: "Project name:",
|
|
47
|
-
default: "my-worker",
|
|
48
|
-
required: true,
|
|
49
|
-
noTTY: "Provide the project name with --project"
|
|
36
|
+
noTTY: "Provide the path to the new worker project with --directory"
|
|
50
37
|
});
|
|
51
38
|
}
|
|
52
|
-
if (!directoryName
|
|
39
|
+
if (!directoryName) {
|
|
53
40
|
console.log(chalk.red("Cancelled."));
|
|
54
41
|
process.exit(1);
|
|
55
42
|
}
|
|
@@ -60,12 +47,10 @@ async function run() {
|
|
|
60
47
|
spinner.text = "Copying template files...";
|
|
61
48
|
const templatePath = getTemplatePath();
|
|
62
49
|
copyTemplate(templatePath, destPath);
|
|
63
|
-
spinner.text = "Customizing package.json...";
|
|
64
|
-
customizePackageJson(destPath, projectName);
|
|
65
50
|
spinner.succeed(chalk.green("Worker project created successfully!"));
|
|
66
51
|
printNextSteps(directoryName);
|
|
67
52
|
} catch (err) {
|
|
68
|
-
spinner.fail("Failed to create project.");
|
|
53
|
+
spinner.fail("Failed to create worker project.");
|
|
69
54
|
console.error(
|
|
70
55
|
chalk.red(`
|
|
71
56
|
${err instanceof Error ? err.message : String(err)}`)
|
|
@@ -103,16 +88,6 @@ function copyTemplate(templatePath, destPath) {
|
|
|
103
88
|
fs.cpSync(srcPath, destFilePath, { recursive: true });
|
|
104
89
|
}
|
|
105
90
|
}
|
|
106
|
-
function customizePackageJson(destPath, projectName) {
|
|
107
|
-
const packageJsonPath = path.join(destPath, "package.json");
|
|
108
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
109
|
-
packageJson.name = projectName;
|
|
110
|
-
fs.writeFileSync(
|
|
111
|
-
packageJsonPath,
|
|
112
|
-
`${JSON.stringify(packageJson, null, 2)}
|
|
113
|
-
`
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
91
|
function printNextSteps(directoryName) {
|
|
117
92
|
console.log(chalk.cyan(`
|
|
118
93
|
\u2728 Next steps:`));
|
package/package.json
CHANGED
package/template/README.md
CHANGED
|
@@ -76,6 +76,7 @@ The sample worker installs three capabilities:
|
|
|
76
76
|
|
|
77
77
|
- [Synced database](#try-the-synced-database)
|
|
78
78
|
- [Agent tool](#try-the-agent-tool)
|
|
79
|
+
- [Automation](#try-the-automation)
|
|
79
80
|
|
|
80
81
|
#### Try the synced database
|
|
81
82
|
|
|
@@ -108,6 +109,19 @@ Save settings, then navigate to the **chat** tab. Our sample tool call allows
|
|
|
108
109
|
for searching tasks by id or keyword - try asking Agent to find tasks related to
|
|
109
110
|
"Ajax" or "worker".
|
|
110
111
|
|
|
112
|
+
#### Try the automation
|
|
113
|
+
|
|
114
|
+
Add a column to your Sample Tasks synced database with type Button. Modify the button automation to `Run Worker` and then choose your worker and the `Mark Task Complete` automation.
|
|
115
|
+
|
|
116
|
+
Once configured, click the button.
|
|
117
|
+
|
|
118
|
+
You will see `Button automation ran successfully`.
|
|
119
|
+
|
|
120
|
+
The automation only prints to console. To see the logs:
|
|
121
|
+
1. Navigate to the `Workers` tab
|
|
122
|
+
2. Select your worker
|
|
123
|
+
3. In `Recent runs` click `automation:completeTaskAutomation`
|
|
124
|
+
|
|
111
125
|
## How-to build your own
|
|
112
126
|
|
|
113
127
|
Begin by using `npm init @project-ajax`, and then customize `index.ts` with
|