-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lint all files with self-consuming config, create lint step in workflow
- Loading branch information
1 parent
2c5ded2
commit 29bd9f1
Showing
10 changed files
with
94 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
### Push to npmjs.com | ||
|
||
```sh | ||
npm publish --access public | ||
``` | ||
Read more on npmjs.com [Publishing scoped public packages](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages). | ||
|
||
Read more on npmjs.com [Publishing scoped public packages](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
import type { PackageManagerRecord } from "./types"; | ||
import type { PackageManagerRecord } from './types' | ||
|
||
export const PACKAGE_NAME = "@monogram/prettier-config"; | ||
export const PACKAGE_NAME = '@monogram/prettier-config' | ||
|
||
export const ESLINT_FILENAME = ".eslintrc.js"; | ||
export const ESLINT_FILENAME = '.eslintrc.js' | ||
|
||
export const AVAILABLE_CONFIGS = ["next", "node"] as const; | ||
export const AVAILABLE_CONFIGS = ['next', 'node'] as const | ||
|
||
export const PACKAGE_MANAGERS = ["yarn", "pnpm", "npm"] as const; | ||
export const PACKAGE_MANAGERS = ['yarn', 'pnpm', 'npm'] as const | ||
|
||
export const LOCK_FILES: PackageManagerRecord = { | ||
yarn: `${process.cwd()}/yarn.lock`, | ||
pnpm: `${process.cwd()}/pnpm-lock.yaml`, | ||
npm: `${process.cwd()}/package-lock.json`, | ||
} as const; | ||
} as const | ||
|
||
export const INSTALL_PREFIXES: PackageManagerRecord = { | ||
yarn: "yarn add -D", | ||
pnpm: "pnpm add -D", | ||
npm: "npm i -D", | ||
} as const; | ||
yarn: 'yarn add -D', | ||
pnpm: 'pnpm add -D', | ||
npm: 'npm i -D', | ||
} as const |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,36 @@ | ||
import { existsSync } from "node:fs"; | ||
import { select, confirm } from "@inquirer/prompts"; | ||
import { LOCK_FILES, PACKAGE_MANAGERS } from "./constants"; | ||
import type { PackageManager } from "./types"; | ||
import { existsSync } from 'node:fs' | ||
import { select, confirm } from '@inquirer/prompts' | ||
import { LOCK_FILES, PACKAGE_MANAGERS } from './constants' | ||
import type { PackageManager } from './types' | ||
|
||
export async function choosePackageManager(): Promise<PackageManager> { | ||
const packageManager = findPackageManager(); | ||
const packageManager = findPackageManager() | ||
|
||
if (packageManager === undefined) { | ||
return selectPackageManager(); | ||
return selectPackageManager() | ||
} | ||
|
||
const useAutoDetected = await confirm({ | ||
message: `Auto-detected package manager. Use ${packageManager} for installation?`, | ||
default: true, | ||
}); | ||
}) | ||
|
||
if (useAutoDetected === false) { | ||
return selectPackageManager(); | ||
return selectPackageManager() | ||
} | ||
|
||
return packageManager; | ||
return packageManager | ||
} | ||
|
||
function findPackageManager(): PackageManager | undefined { | ||
return PACKAGE_MANAGERS.find((packageManager) => | ||
existsSync(LOCK_FILES[packageManager]) | ||
); | ||
return PACKAGE_MANAGERS.find((packageManager) => existsSync(LOCK_FILES[packageManager])) | ||
} | ||
|
||
function selectPackageManager() { | ||
return select({ | ||
message: "Which package manager should be used for installation?", | ||
message: 'Which package manager should be used for installation?', | ||
choices: PACKAGE_MANAGERS.map((packageManager) => ({ | ||
value: packageManager, | ||
})), | ||
}); | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import type { AVAILABLE_CONFIGS, PACKAGE_MANAGERS } from "./constants"; | ||
import type { AVAILABLE_CONFIGS, PACKAGE_MANAGERS } from './constants' | ||
|
||
export type AvailableConfig = (typeof AVAILABLE_CONFIGS)[number]; | ||
export type PackageManager = (typeof PACKAGE_MANAGERS)[number]; | ||
export type AvailableConfig = (typeof AVAILABLE_CONFIGS)[number] | ||
export type PackageManager = (typeof PACKAGE_MANAGERS)[number] | ||
|
||
export type PackageManagerRecord = Record<PackageManager, string>; | ||
export type PackageManagerRecord = Record<PackageManager, string> |