| | |
| | | |
| | | const ORIGIN_NAME = "origin" |
| | | const UPSTREAM_NAME = "upstream" |
| | | const QUARTZ_SOURCE_BRANCH = "v4-alpha" |
| | | const QUARTZ_SOURCE_BRANCH = "v4" |
| | | const cwd = process.cwd() |
| | | const cacheDir = path.join(cwd, ".quartz-cache") |
| | | const cacheFile = "./.quartz-cache/transpiled-build.mjs" |
| | |
| | | |
| | | await rmContentFolder() |
| | | if (setupStrategy === "copy") { |
| | | await fs.promises.cp(originalFolder, contentFolder, { recursive: true }) |
| | | await fs.promises.cp(originalFolder, contentFolder, { |
| | | recursive: true, |
| | | preserveTimestamps: true, |
| | | }) |
| | | } else if (setupStrategy === "symlink") { |
| | | await fs.promises.symlink(originalFolder, contentFolder, "dir") |
| | | } |
| | |
| | | spawnSync("npm", ["i"], { stdio: "inherit" }) |
| | | console.log(chalk.green("Done!")) |
| | | }) |
| | | .command( |
| | | "restore", |
| | | "Try to restore your content folder from the cache", |
| | | CommonArgv, |
| | | async (argv) => { |
| | | const contentFolder = path.join(cwd, argv.directory) |
| | | await popContentFolder(contentFolder) |
| | | }, |
| | | ) |
| | | .command("sync", "Sync your Quartz to and from GitHub.", SyncArgv, async (argv) => { |
| | | const contentFolder = path.join(cwd, argv.directory) |
| | | console.log(chalk.bgGreen.black(`\n Quartz v${version} \n`)) |
| | |
| | | if (argv.commit) { |
| | | const contentStat = await fs.promises.lstat(contentFolder) |
| | | if (contentStat.isSymbolicLink()) { |
| | | const linkTarg = await fs.promises.readlink(contentFolder) |
| | | console.log(chalk.yellow("Detected symlink, trying to dereference before committing")) |
| | | |
| | | // stash symlink file |
| | | await stashContentFolder(contentFolder) |
| | | |
| | | // follow symlink and copy content |
| | | const linkTarg = await fs.promises.readlink(contentFolder) |
| | | await fs.promises.cp(linkTarg, contentFolder, { |
| | | force: true, |
| | | recursive: true, |
| | | preserveTimestamps: true, |
| | | }) |
| | |
| | | dateStyle: "medium", |
| | | timeStyle: "short", |
| | | }) |
| | | spawnSync("git", ["commit", "-am", `Quartz sync: ${currentTimestamp}`], { stdio: "inherit" }) |
| | | spawnSync("git", ["add", "."], { stdio: "inherit" }) |
| | | spawnSync("git", ["commit", "-m", `Quartz sync: ${currentTimestamp}`], { stdio: "inherit" }) |
| | | |
| | | if (contentStat.isSymbolicLink()) { |
| | | // put symlink back |
| | | await popContentFolder() |
| | | await popContentFolder(contentFolder) |
| | | } |
| | | } |
| | | |