Comparing version 0.3.2 to 0.3.3
@@ -1,1 +0,1 @@ | ||
export declare const addChangeset: () => Promise<void>; | ||
export declare const addChangeset: () => Promise<undefined>; |
@@ -5,8 +5,8 @@ import fs from "fs"; | ||
import path from "path"; | ||
import { error } from "./error.js"; | ||
export const addChangeset = async () => { | ||
const ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz"; | ||
const generateChangesetId = customAlphabet(ALPHABET, 8); | ||
if (!fs.existsSync(path.resolve(AURI_DIR))) { | ||
fs.mkdirSync(path.resolve(AURI_DIR)); | ||
} | ||
if (!fs.existsSync(path.join(process.cwd(), AURI_DIR))) | ||
return error(`"${AURI_DIR}" directory does not exist`); | ||
const changesetTemplate = `--- | ||
@@ -16,3 +16,3 @@ package: "" # package name | ||
---`; | ||
fs.writeFileSync(path.resolve(`.auri/$${generateChangesetId()}.md`), changesetTemplate); | ||
fs.writeFileSync(path.join(process.cwd(), AURI_DIR, `$${generateChangesetId()}.md`), changesetTemplate); | ||
}; |
@@ -8,5 +8,6 @@ type Config = { | ||
debug?: boolean; | ||
ignore?: string[]; | ||
}; | ||
type FlatKey<T extends {}> = { | ||
[K in keyof Required<T>]: K extends string ? T[K] extends string | boolean | undefined ? K : Required<T>[K] extends {} ? `${K}.${FlatKey<Required<Required<T>[K]>>}` : never : never; | ||
[K in keyof Required<T>]: K extends string ? T[K] extends string | boolean | undefined | any[] ? K : Required<T>[K] extends {} ? `${K}.${FlatKey<Required<Required<T>[K]>>}` : never : never; | ||
}[keyof Required<T>]; | ||
@@ -13,0 +14,0 @@ type ExtractValueFromFlatKey<Obj extends any, FK extends string> = FK extends `${infer KeyA}.${infer KeyRest}` ? KeyA extends keyof Obj ? Exclude<Obj[KeyA], {}> extends never ? ExtractValueFromFlatKey<Required<Obj>[KeyA], KeyRest> : ExtractValueFromFlatKey<Required<Obj>[KeyA], KeyRest> | undefined : never : FK extends keyof Obj ? Obj[FK] : never; |
{ | ||
"name": "auri", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Organize package changes and releases", | ||
@@ -45,2 +45,3 @@ "main": "index.js", | ||
"front-matter": "^4.0.2", | ||
"ignore": "^5.2.4", | ||
"nanoid": "^4.0.1" | ||
@@ -50,3 +51,3 @@ }, | ||
"build": "shx rm -rf ./dist/* && tsc && shx cp ./package.json ./dist && shx cp ./README.md ./dist", | ||
"auri.publish": "pnpm build && shx rm -rf ./package.json && cd dist && pnpm publish --no-git-checks --access public && cd ../ && shx cp ./dist/package.json ./ && shx rm -rf ./dist/package.json && rm -rf ./dist/README.md", | ||
"auri.publish": "pnpm build && cd dist && pnpm publish --no-git-checks --access public && cd ../", | ||
"auri": "node ./dist/index.js", | ||
@@ -53,0 +54,0 @@ "format": "pnpm exec prettier -w ." |
@@ -5,2 +5,3 @@ import fs from "fs"; | ||
import { config } from "./config.js"; | ||
import ignore from "ignore"; | ||
const isDebugEnabled = config("debug") ?? false; | ||
@@ -29,18 +30,13 @@ export const getPackages = async () => { | ||
}; | ||
const ignoreConfig = config("ignore") ?? []; | ||
const ignoreConfigAbsolutePaths = ignoreConfig.map((configPath) => path.join(process.cwd(), configPath)); | ||
const readdirRecursiveFileSync = (workingAbsolutePath = process.cwd()) => { | ||
const ignoreItemRelativePaths = [".git"]; | ||
const gitignoreFilePath = path.join(workingAbsolutePath, ".gitignore"); | ||
if (fs.existsSync(gitignoreFilePath)) { | ||
const file = fs.readFileSync(gitignoreFilePath); | ||
const fileText = file.toString(); | ||
ignoreItemRelativePaths.push(...fileText.split("\n").filter((val) => !!val && !val.startsWith("#"))); | ||
} | ||
const ignoreItemAbsolutePaths = ignoreItemRelativePaths | ||
.map((relativePath) => path.join(workingAbsolutePath, relativePath)) | ||
.map((filePath) => { | ||
if (!filePath.endsWith("/")) | ||
return filePath; | ||
return filePath.slice(0, -1); | ||
}) | ||
.filter((path) => path !== workingAbsolutePath); | ||
const ig = ignore(); | ||
const defaultIgnoreAbsolutePaths = ["node_modules", ".git"].map((item) => path.join(workingAbsolutePath, item)); | ||
const ignoreItemAbsolutePaths = [ | ||
...ignoreConfigAbsolutePaths, | ||
...defaultIgnoreAbsolutePaths | ||
]; | ||
// ignore only accepts relative paths :( | ||
ig.add(ignoreItemAbsolutePaths.map((val) => `.${val.replace("/", "")}`)); | ||
const absoluteFilePaths = []; | ||
@@ -51,12 +47,10 @@ const dirItemNames = fs.readdirSync(workingAbsolutePath); | ||
const stat = fs.lstatSync(absoluteItemPath); | ||
if (stat.isFile() && !ignoreItemAbsolutePaths.includes(absoluteItemPath)) { | ||
const ignoreItem = ig.ignores(`.${absoluteItemPath.replace("/", "")}`); | ||
if (ignoreItem) | ||
continue; | ||
if (stat.isFile()) { | ||
absoluteFilePaths.push(absoluteItemPath); | ||
continue; | ||
} | ||
if (stat.isFile()) | ||
continue; | ||
const isDir = stat.isDirectory(); | ||
const ignoreDir = isDir && | ||
ignoreItemAbsolutePaths.some((itemPath) => absoluteItemPath.startsWith(itemPath)); | ||
if (isDir && !ignoreDir) { | ||
if (stat.isDirectory()) { | ||
const nestedItemPaths = readdirRecursiveFileSync(absoluteItemPath); | ||
@@ -63,0 +57,0 @@ absoluteFilePaths.push(...nestedItemPaths); |
@@ -30,5 +30,15 @@ # Auri | ||
### `ignore` | ||
`string[]`. Paths to ignore when searching for packages. `node_modules` and `.git` already included. | ||
```json | ||
{ | ||
"repository": ["dist"] | ||
} | ||
``` | ||
### `repository` | ||
**Required** Full Github repository url. | ||
**Required** `string`. Full Github repository url. | ||
@@ -45,3 +55,3 @@ ```json | ||
Command for formatting code. Will run after Auri updates your changelogs and package.json. | ||
`string`. Command for formatting code. Will run after Auri updates your changelogs and package.json. | ||
@@ -58,3 +68,3 @@ ```json | ||
Command to run before any publish command runs. | ||
`string`. Command to run before any publish command runs. | ||
@@ -61,0 +71,0 @@ ```json |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102
29539
5
673
+ Addedignore@^5.2.4
+ Addedignore@5.3.2(transitive)