This commit is contained in:
Adam Matthiesen 2024-01-28 20:53:26 -08:00
parent c4335adc91
commit 8f51cf3fd1
8 changed files with 62 additions and 69 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@matthiesenxyz/create-astro-ghostcms",
"version": "0.0.3-testfix1",
"version": "0.0.3-testfix2",
"description": "Utility to quickly get started with our Integration and astro",
"type": "module",
"main": "./create-astro-ghostcms.mjs",

View File

@ -1,10 +0,0 @@
import * as p from "@clack/prompts";
import c from "picocolors";
/**
* @returns {never}
*/
export function exitPrompt() {
p.cancel(c.red("Operation Cancelled"));
process.exit(0);
}

View File

@ -1,13 +0,0 @@
import path from "node:path";
import { fileURLToPath } from "node:url";
/**
* @param {string} url
*/
export function getModulePaths(url) {
const pathname = fileURLToPath(url);
const parts = pathname.split("/");
const basename = parts.pop();
const dirname = parts.join(path.sep);
return { pathname, dirname, basename };
}

View File

@ -1,6 +1,61 @@
export * from "./exitPrompt";
export * from "./getModulePaths";
export * from "./isPackageManager";
export * from "./isPathname";
export * from "./normalizePath";
export * from "./wait";
import * as p from "@clack/prompts";
import c from "picocolors";
import path from "node:path";
import os from "node:os";
import { fileURLToPath } from "node:url";
/**
* @returns {never}
*/
export function exitPrompt() {
p.cancel(c.red("Operation Cancelled"));
process.exit(0);
}
/**
* @param {string} url
*/
export function getModulePaths(url) {
const pathname = fileURLToPath(url);
const parts = pathname.split("/");
const basename = parts.pop();
const dirname = parts.join(path.sep);
return { pathname, dirname, basename };
}
/**
*
* @param {string} str
* @returns {str is PackageManager}
*/
export function isPackageManager(str) {
return str === "npm" || str === "yarn" || str === "pnpm";
}
/**
* @typedef {import("../../types").PackageManager} PackageManager
*/
/**
* @param {string} str
*/
export function isPathname(str) {
return str.includes(path.sep);
}
/**
* @param {string} pathname
*/
export function normalizePath(pathname) {
if (os.platform() === "win32") {
return path.win32.normalize(pathname);
}
return path.normalize(pathname);
}
/**
* @param {number} ms
*/
export async function wait(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

View File

@ -1,12 +0,0 @@
/**
*
* @param {string} str
* @returns {str is PackageManager}
*/
export function isPackageManager(str) {
return str === "npm" || str === "yarn" || str === "pnpm";
}
/**
* @typedef {import("../../types").PackageManager} PackageManager
*/

View File

@ -1,8 +0,0 @@
import path from "node:path";
/**
* @param {string} str
*/
export function isPathname(str) {
return str.includes(path.sep);
}

View File

@ -1,12 +0,0 @@
import path from "node:path";
import os from "node:os";
/**
* @param {string} pathname
*/
export function normalizePath(pathname) {
if (os.platform() === "win32") {
return path.win32.normalize(pathname);
}
return path.normalize(pathname);
}

View File

@ -1,7 +0,0 @@
/**
* @param {number} ms
*/
export async function wait(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}