Skip to content

Commit

Permalink
add init script (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroki0525 authored Nov 8, 2023
1 parent 0180a38 commit ebaa260
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
scripts
21 changes: 21 additions & 0 deletions packages/ui/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node

import { copyFile, mkdir, readdir, rm } from "fs/promises";

const scriptsDir = "./scripts";
const templatesDir = "./templates";

try {
await rm(scriptsDir, { recursive: true });
} catch {
// no such file or directory error
}
await mkdir(scriptsDir);
const templateFiles = await readdir(templatesDir);
await Promise.all(
templateFiles.map(async (templateFile) => {
const templateFilePath = `${templatesDir}/${templateFile}`;
const scriptFilePath = `${scriptsDir}/${templateFile}`;
await copyFile(templateFilePath, scriptFilePath);
}),
);
5 changes: 3 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"type": "module",
"scripts": {
"build": "tsup --config ../../tsup.config.ts",
"dev:miro": "tsx ./scripts/generateDandoriMiroCards.ts",
"dev:notion": "tsx ./scripts/generateDandoriNotionPages.ts",
"init": "tsx init.ts",
"dev:miro": "tsx script/generateDandoriMiroCards.ts",
"dev:notion": "tsx script/generateDandoriNotionPages.ts",
"test": "vitest run"
},
"keywords": [],
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./miro";
export * from "./notion";
2 changes: 1 addition & 1 deletion packages/ui/src/notion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const createPageParams = (
};
};

export default async function generateDandoriNotionPages(
export async function generateDandoriNotionPages(
tasks: DandoriTask[],
options: GenerateDandoriNotionDatabaseItemsOptions,
): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { loadEnvFile } from "@dandori/libs";
import { tasks } from "./mock";
import generateDandoriNotionPages from "../src/notion";
import { generateDandoriNotionPages } from "@dandori/ui";

// set environment variables like access token
loadEnvFile();
Expand Down
File renamed without changes.

0 comments on commit ebaa260

Please sign in to comment.