Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add init script #46

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.