blokctl 0.2.5 → 0.2.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.
|
@@ -16,7 +16,7 @@ const exec = util.promisify(child_process.exec);
|
|
|
16
16
|
const HOME_DIR = `${os.homedir()}/.blok`;
|
|
17
17
|
const GITHUB_REPO_LOCAL = `${HOME_DIR}/blok`;
|
|
18
18
|
const GITHUB_REPO_REMOTE = "https://github.com/well-prado/blok.git";
|
|
19
|
-
const GITHUB_REPO_RELEASE_TAG = "v0.
|
|
19
|
+
const GITHUB_REPO_RELEASE_TAG = "v0.2.2";
|
|
20
20
|
fsExtra.ensureDirSync(HOME_DIR);
|
|
21
21
|
const options = {
|
|
22
22
|
baseDir: HOME_DIR,
|
|
@@ -312,6 +312,7 @@ export async function createProject(opts, version, currentPath = false, localRep
|
|
|
312
312
|
const triggerDestDir = `${dirPath}/src/triggers/${triggerKind}`;
|
|
313
313
|
fixRunnerImportPaths(triggerDestDir, triggerKind);
|
|
314
314
|
}
|
|
315
|
+
replaceBlokImportsInDirectory(`${dirPath}/src`);
|
|
315
316
|
const sharedNodesContent = generateSharedNodesFile(selectedTriggers, repoSource);
|
|
316
317
|
fsExtra.writeFileSync(`${dirPath}/src/Nodes.ts`, sharedNodesContent);
|
|
317
318
|
const sharedWorkflowsContent = generateSharedWorkflowsFile(selectedTriggers);
|
|
@@ -789,6 +790,24 @@ if (process.env.DISABLE_TRIGGER_RUN !== "true") {
|
|
|
789
790
|
console.log("${triggerKind} trigger not yet implemented");
|
|
790
791
|
`;
|
|
791
792
|
}
|
|
793
|
+
function replaceBlokImportsInDirectory(dirPath) {
|
|
794
|
+
const files = fsExtra.readdirSync(dirPath, { withFileTypes: true });
|
|
795
|
+
for (const file of files) {
|
|
796
|
+
const fullPath = path.join(dirPath, file.name);
|
|
797
|
+
if (file.isDirectory()) {
|
|
798
|
+
if (file.name !== "node_modules" && file.name !== ".blok") {
|
|
799
|
+
replaceBlokImportsInDirectory(fullPath);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
else if (file.name.endsWith(".ts") || file.name.endsWith(".tsx")) {
|
|
803
|
+
let content = fsExtra.readFileSync(fullPath, "utf8");
|
|
804
|
+
if (content.includes("@blok/")) {
|
|
805
|
+
content = content.replace(/@blok\//g, "@blokjs/");
|
|
806
|
+
fsExtra.writeFileSync(fullPath, content);
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
}
|
|
792
811
|
function fixRunnerImportPaths(triggerDestDir, triggerKind) {
|
|
793
812
|
const filesToFix = [];
|
|
794
813
|
if (triggerKind === "http") {
|
|
@@ -840,7 +859,7 @@ function updatePubSubProvider(triggerDestDir, provider) {
|
|
|
840
859
|
const config = adapterConfigs[provider];
|
|
841
860
|
if (!config)
|
|
842
861
|
return;
|
|
843
|
-
content = content.replace(/import \{
|
|
862
|
+
content = content.replace(/import \{ (\w+), (\w+) \} from ["']@blokjs\/trigger-pubsub["'];/, `import { ${config.importName}, PubSubTrigger } from "@blokjs/trigger-pubsub";`);
|
|
844
863
|
content = content.replace(/(export default class \w+ extends PubSubTrigger \{[\s\S]*?)\n\tprotected adapter = new \w+\(\{[\s\S]*?\}\);/, `$1\n\tprotected adapter = ${config.init};`);
|
|
845
864
|
fsExtra.writeFileSync(serverPath, content);
|
|
846
865
|
}
|
|
@@ -880,7 +899,7 @@ function updateQueueProvider(triggerDestDir, provider) {
|
|
|
880
899
|
const config = adapterConfigs[provider];
|
|
881
900
|
if (!config)
|
|
882
901
|
return;
|
|
883
|
-
content = content.replace(/import \{
|
|
902
|
+
content = content.replace(/import \{ (\w+), (\w+) \} from ["']@blokjs\/trigger-queue["'];/, `import { ${config.importName}, QueueTrigger } from "@blokjs/trigger-queue";`);
|
|
884
903
|
content = content.replace(/(export default class \w+ extends QueueTrigger \{[\s\S]*?)\n\tprotected adapter = new \w+\(\{[\s\S]*?\}\);/, `$1\n\tprotected adapter = ${config.init};`);
|
|
885
904
|
fsExtra.writeFileSync(serverPath, content);
|
|
886
905
|
}
|