@hapico/cli 0.0.6 → 0.0.8
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/bin/index.js +8 -2
- package/dist/index.js +8 -2
- package/index.ts +15 -10
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -72,7 +72,9 @@ const getStoredToken = () => {
|
|
|
72
72
|
// Function to save project ID
|
|
73
73
|
const saveProjectId = (projectDir, id) => {
|
|
74
74
|
const configFile = path.join(projectDir, "hapico.config.json");
|
|
75
|
-
fs.writeFileSync(configFile, JSON.stringify({ projectId: id }, null, 2), {
|
|
75
|
+
fs.writeFileSync(configFile, JSON.stringify({ projectId: id }, null, 2), {
|
|
76
|
+
encoding: "utf8",
|
|
77
|
+
});
|
|
76
78
|
};
|
|
77
79
|
// Function to get stored project ID
|
|
78
80
|
const getStoredProjectId = (projectDir) => {
|
|
@@ -120,6 +122,10 @@ class FileManager {
|
|
|
120
122
|
this.writeFile(file);
|
|
121
123
|
}
|
|
122
124
|
}
|
|
125
|
+
replaceSplashWithSeparator(filePath) {
|
|
126
|
+
// Thay thế dấu "\" với dấu "/" trong đường dẫn file
|
|
127
|
+
return filePath.replace(/\\/g, "/");
|
|
128
|
+
}
|
|
123
129
|
listFiles() {
|
|
124
130
|
const files = [];
|
|
125
131
|
const traverseDirectory = (dir) => {
|
|
@@ -132,7 +138,7 @@ class FileManager {
|
|
|
132
138
|
else if (entry.isFile()) {
|
|
133
139
|
const content = fs.readFileSync(fullPath, { encoding: "utf8" });
|
|
134
140
|
files.push({
|
|
135
|
-
path: fullPath.replace(this.basePath + path.sep, "./"),
|
|
141
|
+
path: this.replaceSplashWithSeparator(fullPath.replace(this.basePath + path.sep, "./")),
|
|
136
142
|
content,
|
|
137
143
|
es5: (_a = (0, exports.compileES5)(content, fullPath)) !== null && _a !== void 0 ? _a : "",
|
|
138
144
|
});
|
package/dist/index.js
CHANGED
|
@@ -72,7 +72,9 @@ const getStoredToken = () => {
|
|
|
72
72
|
// Function to save project ID
|
|
73
73
|
const saveProjectId = (projectDir, id) => {
|
|
74
74
|
const configFile = path.join(projectDir, "hapico.config.json");
|
|
75
|
-
fs.writeFileSync(configFile, JSON.stringify({ projectId: id }, null, 2), {
|
|
75
|
+
fs.writeFileSync(configFile, JSON.stringify({ projectId: id }, null, 2), {
|
|
76
|
+
encoding: "utf8",
|
|
77
|
+
});
|
|
76
78
|
};
|
|
77
79
|
// Function to get stored project ID
|
|
78
80
|
const getStoredProjectId = (projectDir) => {
|
|
@@ -120,6 +122,10 @@ class FileManager {
|
|
|
120
122
|
this.writeFile(file);
|
|
121
123
|
}
|
|
122
124
|
}
|
|
125
|
+
replaceSplashWithSeparator(filePath) {
|
|
126
|
+
// Thay thế dấu "\" với dấu "/" trong đường dẫn file
|
|
127
|
+
return filePath.replace(/\\/g, "/");
|
|
128
|
+
}
|
|
123
129
|
listFiles() {
|
|
124
130
|
const files = [];
|
|
125
131
|
const traverseDirectory = (dir) => {
|
|
@@ -132,7 +138,7 @@ class FileManager {
|
|
|
132
138
|
else if (entry.isFile()) {
|
|
133
139
|
const content = fs.readFileSync(fullPath, { encoding: "utf8" });
|
|
134
140
|
files.push({
|
|
135
|
-
path: fullPath.replace(this.basePath + path.sep, "./"),
|
|
141
|
+
path: this.replaceSplashWithSeparator(fullPath.replace(this.basePath + path.sep, "./")),
|
|
136
142
|
content,
|
|
137
143
|
es5: (_a = (0, exports.compileES5)(content, fullPath)) !== null && _a !== void 0 ? _a : "",
|
|
138
144
|
});
|
package/index.ts
CHANGED
|
@@ -47,11 +47,9 @@ const getStoredToken = (): string | null => {
|
|
|
47
47
|
// Function to save project ID
|
|
48
48
|
const saveProjectId = (projectDir: string, id: string) => {
|
|
49
49
|
const configFile = path.join(projectDir, "hapico.config.json");
|
|
50
|
-
fs.writeFileSync(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
{ encoding: "utf8" }
|
|
54
|
-
);
|
|
50
|
+
fs.writeFileSync(configFile, JSON.stringify({ projectId: id }, null, 2), {
|
|
51
|
+
encoding: "utf8",
|
|
52
|
+
});
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
// Function to get stored project ID
|
|
@@ -133,6 +131,11 @@ class FileManager {
|
|
|
133
131
|
}
|
|
134
132
|
}
|
|
135
133
|
|
|
134
|
+
private replaceSplashWithSeparator(filePath: string): string {
|
|
135
|
+
// Thay thế dấu "\" với dấu "/" trong đường dẫn file
|
|
136
|
+
return filePath.replace(/\\/g, "/");
|
|
137
|
+
}
|
|
138
|
+
|
|
136
139
|
public listFiles(): FileContent[] {
|
|
137
140
|
const files: FileContent[] = [];
|
|
138
141
|
const traverseDirectory = (dir: string) => {
|
|
@@ -143,7 +146,7 @@ class FileManager {
|
|
|
143
146
|
} else if (entry.isFile()) {
|
|
144
147
|
const content = fs.readFileSync(fullPath, { encoding: "utf8" });
|
|
145
148
|
files.push({
|
|
146
|
-
path: fullPath.replace(this.basePath + path.sep, "./"),
|
|
149
|
+
path: this.replaceSplashWithSeparator(fullPath.replace(this.basePath + path.sep, "./")),
|
|
147
150
|
content,
|
|
148
151
|
es5: compileES5(content, fullPath) ?? "",
|
|
149
152
|
});
|
|
@@ -571,7 +574,7 @@ program
|
|
|
571
574
|
const apiSpinner: Ora = ora("Fetching latest project files...").start();
|
|
572
575
|
try {
|
|
573
576
|
const response: ApiResponse = await axios.get(
|
|
574
|
-
`https://base.myworkbeast.com/api/views/${projectId}`,
|
|
577
|
+
`https://base.myworkbeast.com/api/views/${projectId}`,
|
|
575
578
|
{
|
|
576
579
|
headers: {
|
|
577
580
|
Authorization: `Bearer ${token}`,
|
|
@@ -584,8 +587,10 @@ program
|
|
|
584
587
|
fileManager.syncFiles(files);
|
|
585
588
|
apiSpinner.succeed("Project files updated successfully!");
|
|
586
589
|
} catch (error) {
|
|
587
|
-
apiSpinner.fail(
|
|
590
|
+
apiSpinner.fail(
|
|
591
|
+
`Error fetching project files: ${(error as Error).message}`
|
|
592
|
+
);
|
|
588
593
|
}
|
|
589
594
|
});
|
|
590
|
-
|
|
591
|
-
program.parse(process.argv);
|
|
595
|
+
|
|
596
|
+
program.parse(process.argv);
|