@upleveled/preflight 1.18.4 → 1.18.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preflight.esm.js +20 -17
- package/dist/preflight.esm.js.map +1 -1
- package/dist/types/TaskParam.d.ts +2 -3
- package/package.json +40 -33
- package/src/checks/allChangesCommittedToGit.ts +3 -3
- package/src/checks/eslint.ts +2 -2
- package/src/checks/eslintConfigIsValid.ts +2 -2
- package/src/checks/linkOnGithubAbout.ts +2 -2
- package/src/checks/noDependencyProblems/noDependenciesWithoutTypes.ts +2 -0
- package/src/checks/noDependencyProblems/noUnusedDependencies.ts +5 -2
- package/src/checks/noExtraneousFilesCommittedToGit.ts +2 -2
- package/src/checks/noSecretsCommittedToGit.ts +2 -2
- package/src/checks/nodeModulesIgnoredFromGit.ts +3 -5
- package/src/checks/preflightIsLatestVersion.ts +2 -2
- package/src/checks/prettier.ts +2 -2
- package/src/checks/useSinglePackageManager.ts +2 -2
- package/src/types/TaskParam.ts +2 -3
- package/src/util/isDrone.ts +2 -2
- package/src/util/preflightBinPath.ts +2 -2
package/dist/preflight.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promises, existsSync } from 'node:fs';
|
|
2
2
|
import { fileURLToPath, URL } from 'node:url';
|
|
3
3
|
import { Listr } from 'listr2';
|
|
4
|
-
import
|
|
4
|
+
import { execaCommand } from 'execa';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
7
|
import readdirp from 'readdirp';
|
|
@@ -22,7 +22,7 @@ function commandExample(command) {
|
|
|
22
22
|
async function isDrone() {
|
|
23
23
|
const {
|
|
24
24
|
stdout
|
|
25
|
-
} = await
|
|
25
|
+
} = await execaCommand('cat /etc/os-release', {
|
|
26
26
|
reject: false
|
|
27
27
|
});
|
|
28
28
|
return /Alpine Linux/.test(stdout);
|
|
@@ -32,7 +32,7 @@ const title = 'All changes committed to Git';
|
|
|
32
32
|
async function allChangesCommittedToGit() {
|
|
33
33
|
const {
|
|
34
34
|
stdout: replSlug
|
|
35
|
-
} = await
|
|
35
|
+
} = await execaCommand('echo $REPL_SLUG');
|
|
36
36
|
const isRunningInReplIt = replSlug !== '';
|
|
37
37
|
|
|
38
38
|
if (isRunningInReplIt) {
|
|
@@ -41,7 +41,7 @@ async function allChangesCommittedToGit() {
|
|
|
41
41
|
|
|
42
42
|
const {
|
|
43
43
|
stdout
|
|
44
|
-
} = await
|
|
44
|
+
} = await execaCommand('git status --porcelain');
|
|
45
45
|
|
|
46
46
|
if (stdout !== '') {
|
|
47
47
|
const onlyYarnLockModifiedOnDrone = stdout.trim() === 'M yarn.lock' && (await isDrone());
|
|
@@ -73,7 +73,7 @@ function normalizeNewline(input) {
|
|
|
73
73
|
const title$1 = 'ESLint';
|
|
74
74
|
async function eslintCheck() {
|
|
75
75
|
try {
|
|
76
|
-
await
|
|
76
|
+
await execaCommand('yarn eslint . --max-warnings 0 --format compact');
|
|
77
77
|
} catch (error) {
|
|
78
78
|
const {
|
|
79
79
|
stdout
|
|
@@ -117,7 +117,7 @@ const title$2 = 'ESLint config is latest version';
|
|
|
117
117
|
async function eslintConfigIsValid() {
|
|
118
118
|
const {
|
|
119
119
|
stdout: remoteVersion
|
|
120
|
-
} = await
|
|
120
|
+
} = await execaCommand('npm show @upleveled/eslint-config-upleveled version');
|
|
121
121
|
let localVersion;
|
|
122
122
|
|
|
123
123
|
try {
|
|
@@ -193,7 +193,7 @@ const title$3 = 'GitHub repo has deployed project link under About';
|
|
|
193
193
|
async function linkOnGithubAbout() {
|
|
194
194
|
const {
|
|
195
195
|
stdout
|
|
196
|
-
} = await
|
|
196
|
+
} = await execaCommand('git remote get-url origin');
|
|
197
197
|
const repoUrl = stdout.replace('git@github.com:', 'https://github.com/').replace('.git', '');
|
|
198
198
|
const html = await (await fetch(repoUrl)).text();
|
|
199
199
|
const $ = cheerio.load(html);
|
|
@@ -227,14 +227,14 @@ var linkOnGithubAbout$1 = {
|
|
|
227
227
|
|
|
228
228
|
const title$4 = 'node_modules/ folder ignored in Git';
|
|
229
229
|
async function nodeModulesIgnoredFromGit() {
|
|
230
|
-
if ((await
|
|
230
|
+
if ((await execaCommand('git ls-files node_modules/')).stdout !== '') {
|
|
231
231
|
throw new Error(`node_modules/ folder committed to Git. Remove it using:
|
|
232
232
|
|
|
233
233
|
${commandExample('git rm -r --cached node_modules')}
|
|
234
234
|
`);
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
if ((await
|
|
237
|
+
if ((await execaCommand('git ls-files .gitignore')).stdout !== '.gitignore') {
|
|
238
238
|
throw new Error('.gitignore file not found');
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -316,19 +316,22 @@ async function noDependenciesWithoutTypes() {
|
|
|
316
316
|
throw new Error(`Dependencies found without types. Add the missing types with:
|
|
317
317
|
|
|
318
318
|
${commandExample(`yarn add --dev ${dependenciesWithMissingTypes.map(([, definitelyTypedPackageName]) => definitelyTypedPackageName).join(' ')}`)}
|
|
319
|
+
|
|
320
|
+
If the dependencies above are already in your package.json, check that they have not been incorrectly installed as regular dependencies in the "dependencies" object - they should be installed inside "devDependencies" (using the --dev flag mentioned above). To fix this situation, remove the dependencies and run the command above exactly.
|
|
319
321
|
`);
|
|
320
322
|
}
|
|
321
323
|
}
|
|
322
324
|
|
|
323
325
|
const {
|
|
324
326
|
stdout: preflightBinPath
|
|
325
|
-
} = await /*#__PURE__*/
|
|
327
|
+
} = await /*#__PURE__*/execaCommand(`yarn bin`, {
|
|
326
328
|
cwd: /*#__PURE__*/dirname( /*#__PURE__*/fileURLToPath(import.meta.url))
|
|
327
329
|
});
|
|
328
330
|
|
|
329
331
|
const title$6 = 'No unused dependencies';
|
|
330
332
|
async function noUnusedAndMissingDependencies() {
|
|
331
|
-
const ignoredPackagePatterns = [// Unused dependency detected in
|
|
333
|
+
const ignoredPackagePatterns = [// Unused dependency detected in https://github.com/upleveled/next-portfolio-dev
|
|
334
|
+
'@graphql-codegen/cli', // Unused dependency detected in create-react-app
|
|
332
335
|
'@testing-library/jest-dom', '@testing-library/react', '@testing-library/user-event', 'react-scripts', 'web-vitals', // Tailwind CSS
|
|
333
336
|
'@tailwindcss/jit', 'autoprefixer', 'postcss', 'tailwindcss', // ESLint configuration
|
|
334
337
|
'@babel/eslint-parser', '@next/eslint-plugin-next', '@typescript-eslint/*', '@upleveled/eslint-config-upleveled', '@upleveled/eslint-plugin-upleveled', 'babel-eslint', 'eslint', 'eslint-config-next', 'eslint-config-react-app', 'eslint-import-resolver-typescript', 'eslint-plugin-*', // Testing
|
|
@@ -337,7 +340,7 @@ async function noUnusedAndMissingDependencies() {
|
|
|
337
340
|
'sharp'].join(',');
|
|
338
341
|
|
|
339
342
|
try {
|
|
340
|
-
await
|
|
343
|
+
await execaCommand(`${preflightBinPath}/depcheck --ignores="${ignoredPackagePatterns}"`);
|
|
341
344
|
} catch (error) {
|
|
342
345
|
const {
|
|
343
346
|
stdout
|
|
@@ -378,7 +381,7 @@ const title$7 = 'No extraneous files committed to Git';
|
|
|
378
381
|
async function noExtraneousFilesCommittedToGit() {
|
|
379
382
|
const {
|
|
380
383
|
stdout
|
|
381
|
-
} = await
|
|
384
|
+
} = await execaCommand('git ls-files .DS_Store yarn-error.log npm-debug.log');
|
|
382
385
|
|
|
383
386
|
if (stdout !== '') {
|
|
384
387
|
throw new Error(`Extraneous files committed to Git:
|
|
@@ -403,7 +406,7 @@ const title$8 = 'No secrets committed to Git';
|
|
|
403
406
|
async function noSecretsCommittedToGit() {
|
|
404
407
|
const {
|
|
405
408
|
stdout
|
|
406
|
-
} = await
|
|
409
|
+
} = await execaCommand('git ls-files .env .env*.local');
|
|
407
410
|
|
|
408
411
|
if (stdout !== '') {
|
|
409
412
|
throw new Error(`Secrets committed to Git 😱:
|
|
@@ -434,7 +437,7 @@ const title$9 = 'Preflight is latest version';
|
|
|
434
437
|
async function preflightIsLatestVersion() {
|
|
435
438
|
const {
|
|
436
439
|
stdout: remoteVersion
|
|
437
|
-
} = await
|
|
440
|
+
} = await execaCommand('npm show @upleveled/preflight version');
|
|
438
441
|
const localVersion = JSON.parse(await promises.readFile(new URL('../package.json', import.meta.url), 'utf-8')).version;
|
|
439
442
|
|
|
440
443
|
if (semver.gt(remoteVersion, localVersion)) {
|
|
@@ -454,7 +457,7 @@ var preflightIsLatestVersion$1 = {
|
|
|
454
457
|
const title$a = 'Prettier';
|
|
455
458
|
async function prettierCheck() {
|
|
456
459
|
try {
|
|
457
|
-
await
|
|
460
|
+
await execaCommand(`yarn --silent prettier --list-different ${process.cwd()}/**/*.{js,jsx,ts,jsx} --ignore-path ${process.cwd()}/.eslintignore --config ${process.cwd()}/prettier.config.cjs --end-of-line auto`, {
|
|
458
461
|
cwd: dirname(fileURLToPath(import.meta.url))
|
|
459
462
|
});
|
|
460
463
|
} catch (error) {
|
|
@@ -531,7 +534,7 @@ const title$c = 'Use single package manager';
|
|
|
531
534
|
async function useSinglePackageManager() {
|
|
532
535
|
const {
|
|
533
536
|
stdout
|
|
534
|
-
} = await
|
|
537
|
+
} = await execaCommand('git ls-files package-lock.json');
|
|
535
538
|
|
|
536
539
|
if (stdout !== '') {
|
|
537
540
|
throw new Error(`package-lock.json file committed to Git. Remove it with:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.esm.js","sources":["../src/util/commandExample.ts","../src/util/isDrone.ts","../src/checks/allChangesCommittedToGit.ts","../src/util/normalizeNewline.ts","../src/checks/eslint.ts","../src/checks/eslintConfigIsValid.ts","../src/util/randomUserAgent.ts","../src/checks/linkOnGithubAbout.ts","../src/checks/nodeModulesIgnoredFromGit.ts","../src/checks/noDependencyProblems/noDependenciesWithoutTypes.ts","../src/util/preflightBinPath.ts","../src/checks/noDependencyProblems/noUnusedDependencies.ts","../src/checks/noExtraneousFilesCommittedToGit.ts","../src/checks/noSecretsCommittedToGit.ts","../src/checks/preflightIsLatestVersion.ts","../src/checks/prettier.ts","../src/checks/projectFolderNameMatchesCorrectFormat.ts","../src/checks/useSinglePackageManager.ts","../src/index.ts"],"sourcesContent":["import chalk from 'chalk';\n\n// https://www.compart.com/en/unicode/U+2800\nconst emptyBrailleCharacter = '';\n\nexport default function commandExample(command: string) {\n return `${emptyBrailleCharacter} ${chalk.dim('$')} ${command}`;\n}\n","import execa from 'execa';\n\nexport async function isDrone() {\n const { stdout } = await execa.command('cat /etc/os-release', {\n reject: false,\n });\n return /Alpine Linux/.test(stdout);\n}\n","import { promises as fs } from 'node:fs';\nimport execa from 'execa';\nimport commandExample from '../util/commandExample';\nimport { isDrone } from '../util/isDrone';\n\nexport const title = 'All changes committed to Git';\n\nexport default async function allChangesCommittedToGit() {\n const { stdout: replSlug } = await execa.command('echo $REPL_SLUG');\n\n const isRunningInReplIt = replSlug !== '';\n\n if (isRunningInReplIt) {\n await fs.writeFile('.git/info/exclude', '.replit\\n');\n }\n\n const { stdout } = await execa.command('git status --porcelain');\n\n if (stdout !== '') {\n const onlyYarnLockModifiedOnDrone =\n stdout.trim() === 'M yarn.lock' && (await isDrone());\n throw new Error(\n `Some changes have not been committed to Git:\n ${stdout}${\n onlyYarnLockModifiedOnDrone\n ? `\n\n The only file with changes is the yarn.lock file, indicating that npm was incorrectly used in addition to Yarn (eg. an \"npm install\" command was run). To fix this, force regeneration of the yarn.lock file locally with the following command and then commit the changes:\n\n ${commandExample('yarn --force')}`\n : ''\n }\n `,\n );\n }\n}\n","const CRLF = '\\r\\n';\n\nexport default function normalizeNewline(input: string) {\n if (typeof input !== 'string') {\n throw new TypeError(`Expected a \\`string\\`, got \\`${typeof input}\\``);\n }\n\n return input.replace(new RegExp(CRLF, 'g'), '\\n');\n}\n","import execa from 'execa';\nimport normalizeNewline from '../util/normalizeNewline';\n\nexport const title = 'ESLint';\n\nexport default async function eslintCheck() {\n try {\n await execa.command('yarn eslint . --max-warnings 0 --format compact');\n } catch (error) {\n const { stdout } = error as { stdout: string };\n const lines = stdout.split('\\n');\n\n // If no ESLint problems detected, throw the error\n if (!/^\\d+ problems?$/.test(lines[lines.length - 2])) {\n throw error;\n }\n\n throw new Error(\n `ESLint problems found in the following files:\n ${normalizeNewline(stdout)\n .split('\\n')\n // Match lines starting with slashes (macOS, Linux) or drive letters (Windows)\n .filter((line) => /^(\\/|[A-Z]:\\\\)/.test(line))\n // Strip out the filename\n .map((line) => line.match(/^(([A-Z]:)?[^:]+):/)?.[1])\n // Remove duplicate filenames\n .reduce((linesWithoutDuplicates: string[], line) => {\n if (line && !linesWithoutDuplicates.includes(line)) {\n linesWithoutDuplicates.push(line);\n }\n return linesWithoutDuplicates;\n }, [])\n .join('\\n')}\n\n Open these files in your editor - there should be problems to fix.\n `,\n );\n }\n}\n","import { promises as fs } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport execa from 'execa';\nimport readdirp from 'readdirp';\nimport semver from 'semver';\nimport commandExample from '../util/commandExample';\n\nconst require = createRequire(`${process.cwd()}/`);\n\nexport const title = 'ESLint config is latest version';\n\nexport default async function eslintConfigIsValid() {\n const { stdout: remoteVersion } = await execa.command(\n 'npm show @upleveled/eslint-config-upleveled version',\n );\n\n let localVersion;\n\n try {\n const eslintConfigPackageJsonPath = require.resolve(\n '@upleveled/eslint-config-upleveled/package.json',\n );\n\n localVersion = JSON.parse(\n await fs.readFile(eslintConfigPackageJsonPath, 'utf-8'),\n ).version;\n } catch (err) {}\n\n if (typeof localVersion === 'undefined') {\n throw new Error(\n `The UpLeveled ESLint config has not been installed. Please install using the instructions on https://www.npmjs.com/package/@upleveled/eslint-config-upleveled\n `,\n );\n }\n\n if (semver.gt(remoteVersion, localVersion)) {\n throw new Error(\n `Your current version of the UpLeveled ESLint config (${localVersion}) is out of date. The latest version is ${remoteVersion}. Upgrade with:\n\n ${commandExample(\n 'yarn upgrade --latest @upleveled/eslint-config-upleveled',\n )}\n `,\n );\n }\n\n let eslintConfigMatches;\n\n try {\n eslintConfigMatches =\n (await fs.readFile('./.eslintrc.cjs', 'utf-8')).trim() ===\n `module.exports = {\n extends: ['@upleveled/upleveled'],\n};`;\n } catch (err) {\n throw new Error(\n `Error reading your .eslintrc.cjs file. Please reinstall the config using the instructions on https://www.npmjs.com/package/@upleveled/eslint-config-upleveled\n `,\n );\n }\n\n if (!eslintConfigMatches) {\n throw new Error(\n `Your ESLint config file .eslintrc.cjs does not match the configuration file template. Please reinstall the config using the instructions on https://www.npmjs.com/package/@upleveled/eslint-config-upleveled\n `,\n );\n }\n\n const eslintDisableOccurrences = [];\n\n for await (const { path } of readdirp('.', {\n directoryFilter: ['!.git', '!.next', '!node_modules'],\n fileFilter: ['*.js', '*.jsx', '*.ts', '*.tsx'],\n })) {\n const fileContents = await fs.readFile(path, 'utf-8');\n if (/eslint-disable|eslint [a-z0-9@/-]+: (0|off)/.test(fileContents)) {\n eslintDisableOccurrences.push(path);\n }\n }\n\n if (eslintDisableOccurrences.length > 0) {\n throw new Error(\n `ESLint has been disabled in the following files:\n ${eslintDisableOccurrences.join('\\n')}\n\n Remove all comments disabling or modifying ESLint rule configuration (eg. eslint-disable and eslint-disable-next-line comments) and fix the problems.\n `,\n );\n }\n}\n","import userAgents from 'top-user-agents';\n\nexport default function randomUserAgent() {\n const randomIndex = Math.floor(Math.random() * (userAgents.length - 1));\n return userAgents[randomIndex];\n}\n","import cheerio from 'cheerio';\nimport type { Element } from 'domhandler';\nimport execa from 'execa';\nimport fetch from 'node-fetch';\nimport randomUserAgent from '../util/randomUserAgent';\n\nexport const title = 'GitHub repo has deployed project link under About';\n\nexport default async function linkOnGithubAbout() {\n const { stdout } = await execa.command('git remote get-url origin');\n\n const repoUrl = stdout\n .replace('git@github.com:', 'https://github.com/')\n .replace('.git', '');\n\n const html = await (await fetch(repoUrl)).text();\n\n const $ = cheerio.load(html);\n\n const urlInAboutSection = $('h2')\n .filter(function (this: Element) {\n return $(this).text().trim() === 'About';\n })\n .nextAll('div')\n .filter(function (this: Element) {\n return $(this).children('.octicon.octicon-link').length > 0;\n })\n .children('.octicon.octicon-link')\n .next()\n .children('a[href]')\n .attr('href');\n\n if (!urlInAboutSection) {\n throw new Error(\n `Deployed project link not found in About section on ${repoUrl}. Click on the cog symbol to the right of the About heading and paste the Repl.it / Netlify / Heroku link in the Website box.`,\n );\n }\n\n const response = await fetch(urlInAboutSection, {\n headers: {\n // For repl.it\n 'user-agent': randomUserAgent(),\n },\n });\n\n if (!response.ok) {\n throw new Error(\n `Project link in About section on ${repoUrl} is not returning a proper status code: the link returns status code ${response.status} (${response.statusText}).`,\n );\n }\n}\n","import { promises as fs } from 'node:fs';\nimport execa from 'execa';\nimport commandExample from '../util/commandExample';\nimport normalizeNewline from '../util/normalizeNewline';\n\nexport const title = 'node_modules/ folder ignored in Git';\n\nexport default async function nodeModulesIgnoredFromGit() {\n if ((await execa.command('git ls-files node_modules/')).stdout !== '') {\n throw new Error(\n `node_modules/ folder committed to Git. Remove it using:\n\n ${commandExample('git rm -r --cached node_modules')}\n `,\n );\n }\n\n if (\n (await execa.command('git ls-files .gitignore')).stdout !== '.gitignore'\n ) {\n throw new Error('.gitignore file not found');\n }\n\n const nodeModulesInGitignore = normalizeNewline(\n await fs.readFile('./.gitignore', 'utf8'),\n )\n .split('\\n')\n .reduce((found, line) => found || /^\\/?node_modules\\/?$/.test(line), false);\n\n if (!nodeModulesInGitignore) {\n throw new Error('node_modules not found in .gitignore');\n }\n}\n","import { existsSync, promises as fs } from 'node:fs';\nimport algoliasearch from 'algoliasearch';\nimport pReduce from 'p-reduce';\nimport commandExample from '../../util/commandExample';\n\nconst client = algoliasearch(\n // Application ID and API key specific to UpLeveled\n // Preflight. Please don't use anywhere else without\n // asking Algolia's permission.\n 'OFCNCOG2CU', // Application ID\n 'ec73550aa8b2936dab436d4e02144784', // API Key\n);\nconst index = client.initIndex('npm-search');\n\ninterface AlgoliaObj {\n types?: {\n definitelyTyped?: string;\n };\n}\n\nexport const title = 'No dependencies without types';\n\n// This is a naive check for matching @types/<pkg name> packages\n// that the student hasn't yet installed. It is not intended to\n// be an exhaustive check for any types for all packages.\n//\n// It attempts to address scenarios such as this with\n// `styled-components`:\n//\n// https://learn.upleveled.io/courses/btcmp-l-webfs-gen-0/modules/122-cheatsheet-css-in-js/#eslint-errors-with-styled-components\nexport default async function noDependenciesWithoutTypes() {\n const { devDependencies = {}, dependencies = {} } = JSON.parse(\n await fs.readFile('package.json', 'utf-8'),\n );\n\n const dependenciesWithMissingTypes = await pReduce(\n Object.keys(dependencies),\n async (filteredDependencies: [string, string][], dependency: string) => {\n try {\n const packageJsonPath = require.resolve(`${dependency}/package.json`);\n\n const modulePackageJson = JSON.parse(\n await fs.readFile(packageJsonPath, 'utf-8'),\n );\n\n // If the keys \"types\" or \"typings\" are in the module's `package.json`, bail out\n if ('types' in modulePackageJson || 'typings' in modulePackageJson) {\n return filteredDependencies;\n }\n } catch (err) {}\n\n let indexDTsPath;\n\n try {\n indexDTsPath = require.resolve(`${dependency}/index.d.ts`);\n } catch (err) {}\n\n // If the index.d.ts file exists inside the module's directory, bail out\n if (indexDTsPath && existsSync(indexDTsPath)) {\n return filteredDependencies;\n }\n\n const results = await index.getObject<AlgoliaObj>(dependency, {\n attributesToRetrieve: ['types'],\n });\n\n const definitelyTypedPackageName = results.types?.definitelyTyped;\n\n if (definitelyTypedPackageName) {\n // If a matching `@types/<package name>` has been already installed in devDependencies, bail out\n if (Object.keys(devDependencies).includes(definitelyTypedPackageName)) {\n return filteredDependencies;\n }\n\n filteredDependencies.push([dependency, definitelyTypedPackageName]);\n }\n\n return filteredDependencies;\n },\n [],\n );\n\n if (dependenciesWithMissingTypes.length > 0) {\n throw new Error(\n `Dependencies found without types. Add the missing types with:\n\n ${commandExample(\n `yarn add --dev ${dependenciesWithMissingTypes\n .map(([, definitelyTypedPackageName]) => definitelyTypedPackageName)\n .join(' ')}`,\n )}\n `,\n );\n }\n}\n","import { dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport execa from 'execa';\n\nconst { stdout: preflightBinPath } = await execa.command(`yarn bin`, {\n cwd: dirname(fileURLToPath(import.meta.url)),\n});\n\nexport default preflightBinPath;\n","import execa from 'execa';\nimport commandExample from '../../util/commandExample';\nimport preflightBinPath from '../../util/preflightBinPath';\n\nexport const title = 'No unused dependencies';\n\nexport default async function noUnusedAndMissingDependencies() {\n const ignoredPackagePatterns = [\n // Unused dependency detected in create-react-app\n '@testing-library/jest-dom',\n '@testing-library/react',\n '@testing-library/user-event',\n 'react-scripts',\n 'web-vitals',\n\n // Tailwind CSS\n '@tailwindcss/jit',\n 'autoprefixer',\n 'postcss',\n 'tailwindcss',\n\n // ESLint configuration\n '@babel/eslint-parser',\n '@next/eslint-plugin-next',\n '@typescript-eslint/*',\n '@upleveled/eslint-config-upleveled',\n '@upleveled/eslint-plugin-upleveled',\n 'babel-eslint',\n 'eslint',\n 'eslint-config-next',\n 'eslint-config-react-app',\n 'eslint-import-resolver-typescript',\n 'eslint-plugin-*',\n\n // Testing\n 'babel-jest',\n 'jest',\n 'cypress',\n\n // TypeScript\n 'typescript',\n '@types/*',\n\n // Next.js\n 'sharp',\n ].join(',');\n\n try {\n await execa.command(\n `${preflightBinPath}/depcheck --ignores=\"${ignoredPackagePatterns}\"`,\n );\n } catch (error) {\n const { stdout } = error as { stdout: string };\n if (\n !stdout.startsWith('Unused dependencies') &&\n !stdout.startsWith('Unused devDependencies') &&\n !stdout.startsWith('Missing dependencies')\n ) {\n throw error;\n }\n\n const [unusedDependenciesStdout, missingDependenciesStdout] = stdout.split(\n 'Missing dependencies',\n );\n\n const messages = [];\n\n if (unusedDependenciesStdout) {\n messages.push(`Unused dependencies found:\n ${unusedDependenciesStdout\n .split('\\n')\n .filter((str: string) => str.includes('* '))\n .join('\\n')}\n\n Remove these dependencies by running the following command for each dependency:\n\n ${commandExample('yarn remove <dependency name here>')}\n `);\n }\n\n if (missingDependenciesStdout) {\n messages.push(`Missing dependencies found:\n ${missingDependenciesStdout\n .split('\\n')\n .filter((str: string) => str.includes('* '))\n .join('\\n')}\n\n Add these missing dependencies by running the following command for each dependency:\n\n ${commandExample('yarn add <dependency name here>')}\n `);\n }\n\n throw new Error(messages.join('\\n\\n'));\n }\n}\n","import execa from 'execa';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'No extraneous files committed to Git';\n\nexport default async function noExtraneousFilesCommittedToGit() {\n const { stdout } = await execa.command(\n 'git ls-files .DS_Store yarn-error.log npm-debug.log',\n );\n\n if (stdout !== '') {\n throw new Error(\n `Extraneous files committed to Git:\n ${stdout}\n\n Remove these files from your repo by running the following command for each file:\n\n ${commandExample('git rm --cached <filename here>')}\n\n Once you've removed all files, make sure that it doesn't happen again by adding the filenames above to your .gitignore file.\n `,\n );\n }\n}\n","import execa from 'execa';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'No secrets committed to Git';\n\nexport default async function noSecretsCommittedToGit() {\n const { stdout } = await execa.command('git ls-files .env .env*.local');\n\n if (stdout !== '') {\n throw new Error(\n `Secrets committed to Git 😱:\n ${stdout}\n\n Remove these files from your repo by installing BFG from the System Setup Guide (see Optional Software at the bottom) and running it on each of your files like this:\n\n ${commandExample('bfg --delete-files <filename here>')}\n\n Once you've done this for every secret file, then force push to your repository:\n\n ${commandExample('git push --force')}\n\n More info: https://docs.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository\n\n Finally, make sure that this doesn't happen again by adding the filenames above to your .gitignore file.\n `,\n );\n }\n}\n","import { promises as fs } from 'node:fs';\nimport os from 'node:os';\nimport { URL } from 'node:url';\nimport execa from 'execa';\nimport semver from 'semver';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'Preflight is latest version';\n\nexport default async function preflightIsLatestVersion() {\n const { stdout: remoteVersion } = await execa.command(\n 'npm show @upleveled/preflight version',\n );\n\n const localVersion = JSON.parse(\n await fs.readFile(new URL('../package.json', import.meta.url), 'utf-8'),\n ).version;\n\n if (semver.gt(remoteVersion, localVersion)) {\n throw new Error(\n `Your current version of Preflight (${localVersion}) is out of date. The latest version is ${remoteVersion}. Upgrade with:\n\n ${commandExample(\n `${\n os.platform() === 'linux' ? 'sudo ' : ''\n }yarn global add @upleveled/preflight`,\n )}\n `,\n );\n }\n}\n","import { dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport execa from 'execa';\nimport normalizeNewline from '../util/normalizeNewline';\n\nexport const title = 'Prettier';\n\nexport default async function prettierCheck() {\n try {\n await execa.command(\n `yarn --silent prettier --list-different ${process.cwd()}/**/*.{js,jsx,ts,jsx} --ignore-path ${process.cwd()}/.eslintignore --config ${process.cwd()}/prettier.config.cjs --end-of-line auto`,\n { cwd: dirname(fileURLToPath(import.meta.url)) },\n );\n } catch (error) {\n const { stdout, stderr } = error as { stdout: string; stderr: string };\n\n const stderrWithoutPackageJsonWarning = stderr.replace(\n /warning [/.\\\\]*package\\.json: No license field[\\r\\n]*/g,\n '',\n );\n\n if (!stdout || stderrWithoutPackageJsonWarning) {\n throw error;\n }\n\n const ignoredFilePatterns = [\n // File from create-react-app not matching our formatting\n // https://github.com/facebook/create-react-app/blob/fdbde1f3c256b43d5386b5ae3a75083dbd8f0aff/packages/cra-template/template/src/reportWebVitals.js\n /src[/\\\\]reportWebVitals\\.js$/,\n\n // Files from create-next-app not matching our formatting\n // https://github.com/vercel/next.js/blob/5a73859fe8d3659d52e169f97188ae422e0d2ace/packages/create-next-app/templates/default/pages/api/hello.js\n /pages[/\\\\]api[/\\\\]hello\\.js$/,\n // https://github.com/vercel/next.js/blob/aacfa79ddf88e4e1488b63ac253af27110f0a151/packages/create-next-app/templates/default/pages/_app.js\n /pages[/\\\\]_app\\.js$/,\n ];\n\n const unformattedFiles = normalizeNewline(stdout)\n .split('\\n')\n .map((file) =>\n // Make paths relative to the project instead of Preflight, eg:\n // before: ../../../../../../projects/random-color-generator-react-app/src/reportWebVitals.js\n // after: random-color-generator-react-app/src/reportWebVitals.js\n file.replace(/^([A-Z]:|\\.\\.[/\\\\])[a-zA-Z0-9-_/.\\\\ ]*projects[/\\\\]/, ''),\n )\n .filter(\n (file) =>\n !ignoredFilePatterns.some((ignoredFilePattern) =>\n ignoredFilePattern.test(file),\n ),\n );\n\n if (unformattedFiles.length > 0) {\n throw new Error(\n `Prettier has not been run in the following files:\n ${unformattedFiles.join('\\n')}\n\n First, try opening the files above in your editor and saving them. This should format the file with Prettier.\n\n If the code in these files has already been formatted by Prettier, in very seldom cases, the mismatch may come from inconsistent end of line characters.\n\n Fix this in VS Code like this:\n\n 1. cmd/ctrl-shift-P -> Change End of Line Sequence -> CRLF\n 2. Save the file\n 3. cmd/ctrl-shift-P -> Change End of Line Sequence -> LF\n 4. Save the file\n `,\n );\n }\n }\n}\n","import path from 'node:path';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'Project folder name matches correct format';\n\nexport default function projectFolderNameMatchesCorrectFormat() {\n const currentDirectoryName = path.basename(process.cwd());\n const lowercaseHyphenedDirectoryName = currentDirectoryName\n .toLowerCase()\n .replaceAll(' ', '-');\n\n if (currentDirectoryName !== lowercaseHyphenedDirectoryName) {\n throw new Error(\n `Project directory name \"${currentDirectoryName}\" doesn't match the correct format (no spaces or uppercase letters).\n\n Rename the directory to the correct name \"${lowercaseHyphenedDirectoryName}\" with the following sequence of commands:\n\n ${commandExample('cd ..')}\n ${commandExample(\n `mv ${currentDirectoryName} ${lowercaseHyphenedDirectoryName}`,\n )}\n ${commandExample(`cd ${lowercaseHyphenedDirectoryName}`)}\n `,\n );\n }\n}\n","import execa from 'execa';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'Use single package manager';\n\nexport default async function useSinglePackageManager() {\n const { stdout } = await execa.command('git ls-files package-lock.json');\n\n if (stdout !== '') {\n throw new Error(\n `package-lock.json file committed to Git. Remove it with:\n\n ${commandExample('git rm --cached <filename>')}\n\n After you've removed it, you can delete the file with:\n\n ${commandExample('rm <filename>')}\n\n The presence of this file indicates that npm was incorrectly used in addition to Yarn (eg. an \"npm install\" command was run). In order to avoid issues with the state of the yarn.lock file, we suggest also forcing regeneration this file with the following command:\n\n ${commandExample('yarn --force')}\n `,\n );\n }\n}\n","import { promises as fs } from 'node:fs';\nimport { URL } from 'node:url';\nimport { Listr } from 'listr2';\nimport * as allChangesCommittedToGit from './checks/allChangesCommittedToGit.js';\nimport * as eslint from './checks/eslint.js';\nimport * as eslintConfigIsValid from './checks/eslintConfigIsValid.js';\nimport * as linkOnGithubAbout from './checks/linkOnGithubAbout.js';\nimport * as nodeModulesIgnoredFromGit from './checks/nodeModulesIgnoredFromGit.js';\nimport * as noDependenciesWithoutTypes from './checks/noDependencyProblems/noDependenciesWithoutTypes.js';\nimport * as noUnusedAndMissingDependencies from './checks/noDependencyProblems/noUnusedDependencies.js';\nimport * as noExtraneousFilesCommittedToGit from './checks/noExtraneousFilesCommittedToGit.js';\nimport * as noSecretsCommittedToGit from './checks/noSecretsCommittedToGit.js';\nimport * as preflightIsLatestVersion from './checks/preflightIsLatestVersion.js';\nimport * as prettier from './checks/prettier.js';\nimport * as projectFolderNameMatchesCorrectFormat from './checks/projectFolderNameMatchesCorrectFormat.js';\nimport * as useSinglePackageManager from './checks/useSinglePackageManager.js';\nimport { CtxParam } from './types/CtxParam.js';\nimport { TaskParam } from './types/TaskParam.js';\n\nconst version = JSON.parse(\n await fs.readFile(new URL('../package.json', import.meta.url), 'utf-8'),\n).version;\n\nconsole.log(`🚀 UpLeveled Preflight v${version}`);\n\nconst listrTasks = [\n // ======= Sync Tasks =======\n // Git\n allChangesCommittedToGit,\n nodeModulesIgnoredFromGit,\n noExtraneousFilesCommittedToGit,\n noSecretsCommittedToGit,\n\n // Package managers\n useSinglePackageManager,\n\n // Project setup\n projectFolderNameMatchesCorrectFormat,\n\n // ======= Async Tasks =======\n // Dependencies\n {\n title: 'No dependency problems',\n task: (ctx: CtxParam, task: TaskParam): Listr =>\n task.newListr([\n {\n title: noUnusedAndMissingDependencies.title,\n task: noUnusedAndMissingDependencies.default,\n },\n {\n title: noDependenciesWithoutTypes.title,\n task: noDependenciesWithoutTypes.default,\n },\n ]),\n },\n\n // GitHub\n linkOnGithubAbout,\n\n // Linting\n eslint,\n prettier,\n\n // Version and configuration checks\n eslintConfigIsValid,\n preflightIsLatestVersion,\n].map((module) => {\n if ('task' in module) return module;\n return {\n title: module.title,\n task: module.default,\n };\n});\n\nawait new Listr(listrTasks, {\n exitOnError: false,\n rendererOptions: {\n collapseErrors: false,\n removeEmptyLines: false,\n formatOutput: 'wrap',\n },\n concurrent: 5,\n}).run();\n"],"names":["emptyBrailleCharacter","commandExample","command","chalk","dim","isDrone","stdout","execa","reject","test","title","allChangesCommittedToGit","replSlug","isRunningInReplIt","fs","writeFile","onlyYarnLockModifiedOnDrone","trim","Error","CRLF","normalizeNewline","input","TypeError","replace","RegExp","eslintCheck","error","lines","split","length","filter","line","map","match","reduce","linesWithoutDuplicates","includes","push","join","require","createRequire","process","cwd","eslintConfigIsValid","remoteVersion","localVersion","eslintConfigPackageJsonPath","resolve","JSON","parse","readFile","version","err","semver","gt","eslintConfigMatches","eslintDisableOccurrences","path","readdirp","directoryFilter","fileFilter","fileContents","randomUserAgent","randomIndex","Math","floor","random","userAgents","linkOnGithubAbout","repoUrl","html","fetch","text","$","cheerio","load","urlInAboutSection","nextAll","children","next","attr","response","headers","ok","status","statusText","nodeModulesIgnoredFromGit","nodeModulesInGitignore","found","client","algoliasearch","index","initIndex","noDependenciesWithoutTypes","devDependencies","dependencies","dependenciesWithMissingTypes","pReduce","Object","keys","filteredDependencies","dependency","packageJsonPath","modulePackageJson","indexDTsPath","existsSync","results","getObject","attributesToRetrieve","definitelyTypedPackageName","types","definitelyTyped","preflightBinPath","dirname","fileURLToPath","import","meta","url","noUnusedAndMissingDependencies","ignoredPackagePatterns","startsWith","unusedDependenciesStdout","missingDependenciesStdout","messages","str","noExtraneousFilesCommittedToGit","noSecretsCommittedToGit","preflightIsLatestVersion","URL","os","platform","prettierCheck","stderr","stderrWithoutPackageJsonWarning","ignoredFilePatterns","unformattedFiles","file","some","ignoredFilePattern","projectFolderNameMatchesCorrectFormat","currentDirectoryName","basename","lowercaseHyphenedDirectoryName","toLowerCase","replaceAll","useSinglePackageManager","console","log","listrTasks","task","ctx","newListr","eslint","prettier","module","default","Listr","exitOnError","rendererOptions","collapseErrors","removeEmptyLines","formatOutput","concurrent","run"],"mappings":";;;;;;;;;;;;;;;;AAGA,MAAMA,qBAAqB,GAAG,GAA9B;SAEwBC,eAAeC;AACrC,YAAUF,0BAA0BG,KAAK,CAACC,GAAN,CAAU,GAAV,KAAkBF,SAAtD;AACD;;ACLM,eAAeG,OAAf;AACL,QAAM;AAAEC,IAAAA;AAAF,MAAa,MAAMC,KAAK,CAACL,OAAN,CAAc,qBAAd,EAAqC;AAC5DM,IAAAA,MAAM,EAAE;AADoD,GAArC,CAAzB;AAGA,SAAO,eAAeC,IAAf,CAAoBH,MAApB,CAAP;AACD;;ACFM,MAAMI,KAAK,GAAG,8BAAd;AAEP,AAAe,eAAeC,wBAAf;AACb,QAAM;AAAEL,IAAAA,MAAM,EAAEM;AAAV,MAAuB,MAAML,KAAK,CAACL,OAAN,CAAc,iBAAd,CAAnC;AAEA,QAAMW,iBAAiB,GAAGD,QAAQ,KAAK,EAAvC;;AAEA,MAAIC,iBAAJ,EAAuB;AACrB,UAAMC,QAAE,CAACC,SAAH,CAAa,mBAAb,EAAkC,WAAlC,CAAN;AACD;;AAED,QAAM;AAAET,IAAAA;AAAF,MAAa,MAAMC,KAAK,CAACL,OAAN,CAAc,wBAAd,CAAzB;;AAEA,MAAII,MAAM,KAAK,EAAf,EAAmB;AACjB,UAAMU,2BAA2B,GAC/BV,MAAM,CAACW,IAAP,OAAkB,aAAlB,KAAoC,MAAMZ,OAAO,EAAjD,CADF;AAEA,UAAM,IAAIa,KAAJ;UAEAZ,SACFU,2BAA2B;;;;UAKzBf,cAAc,CAAC,cAAD,GALW,GAMvB;OATF,CAAN;AAaD;AACF;;;;;;;;ACnCD,MAAMkB,IAAI,GAAG,MAAb;AAEA,SAAwBC,iBAAiBC;AACvC,MAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC7B,UAAM,IA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BC,yBANiB;AASjBmB,yBATiB;AAYjBN,uCAZiB;AAejB;AACA;AACEjI,EAAAA,KAAK,EAAE,wBADT;AAEE2I,EAAAA,IAAI,EAAE,CAACC,GAAD,EAAgBD,IAAhB,KACJA,IAAI,CAACE,QAAL,CAAc,CACZ;AACE7I,IAAAA,KAAK,EAAE4G,OADT;AAEE+B,IAAAA,IAAI,EAAE/B;AAFR,GADY,EAKZ;AACE5G,IAAAA,KAAK,EAAEmF,OADT;AAEEwD,IAAAA,IAAI,EAAExD;AAFR,GALY,CAAd;AAHJ,CAhBiB;AAgCjBzB,mBAhCiB;AAmCjBoF,MAnCiB,EAoCjBC,QApCiB;AAuCjB9G,qBAvCiB,EAwCjBoF,0BAxCiB,EAyCjB/F,GAzCiB,CAyCZ0H,MAAD;AACJ,MAAI,UAAUA,MAAd,EAAsB,OAAOA,MAAP;AACtB,SAAO;AACLhJ,IAAAA,KAAK,EAAEgJ,MAAM,CAAChJ,KADT;AAEL2I,IAAAA,IAAI,EAAEK,MAAM,CAACC;AAFR,GAAP;AAID,CA/CkB,CAAnB;AAiDA,MAAM,IAAIC,KAAJ,CAAUR,UAAV,EAAsB;AAC1BS,EAAAA,WAAW,EAAE,KADa;AAE1BC,EAAAA,eAAe,EAAE;AACfC,IAAAA,cAAc,EAAE,KADD;AAEfC,IAAAA,gBAAgB,EAAE,KAFH;AAGfC,IAAAA,YAAY,EAAE;AAHC,GAFS;AAO1BC,EAAAA,UAAU,EAAE;AAPc,CAAtB,EAQHC,GARG,EAAN"}
|
|
1
|
+
{"version":3,"file":"preflight.esm.js","sources":["../src/util/commandExample.ts","../src/util/isDrone.ts","../src/checks/allChangesCommittedToGit.ts","../src/util/normalizeNewline.ts","../src/checks/eslint.ts","../src/checks/eslintConfigIsValid.ts","../src/util/randomUserAgent.ts","../src/checks/linkOnGithubAbout.ts","../src/checks/nodeModulesIgnoredFromGit.ts","../src/checks/noDependencyProblems/noDependenciesWithoutTypes.ts","../src/util/preflightBinPath.ts","../src/checks/noDependencyProblems/noUnusedDependencies.ts","../src/checks/noExtraneousFilesCommittedToGit.ts","../src/checks/noSecretsCommittedToGit.ts","../src/checks/preflightIsLatestVersion.ts","../src/checks/prettier.ts","../src/checks/projectFolderNameMatchesCorrectFormat.ts","../src/checks/useSinglePackageManager.ts","../src/index.ts"],"sourcesContent":["import chalk from 'chalk';\n\n// https://www.compart.com/en/unicode/U+2800\nconst emptyBrailleCharacter = '';\n\nexport default function commandExample(command: string) {\n return `${emptyBrailleCharacter} ${chalk.dim('$')} ${command}`;\n}\n","import { execaCommand } from 'execa';\n\nexport async function isDrone() {\n const { stdout } = await execaCommand('cat /etc/os-release', {\n reject: false,\n });\n return /Alpine Linux/.test(stdout);\n}\n","import { promises as fs } from 'node:fs';\nimport { execaCommand } from 'execa';\nimport commandExample from '../util/commandExample';\nimport { isDrone } from '../util/isDrone';\n\nexport const title = 'All changes committed to Git';\n\nexport default async function allChangesCommittedToGit() {\n const { stdout: replSlug } = await execaCommand('echo $REPL_SLUG');\n\n const isRunningInReplIt = replSlug !== '';\n\n if (isRunningInReplIt) {\n await fs.writeFile('.git/info/exclude', '.replit\\n');\n }\n\n const { stdout } = await execaCommand('git status --porcelain');\n\n if (stdout !== '') {\n const onlyYarnLockModifiedOnDrone =\n stdout.trim() === 'M yarn.lock' && (await isDrone());\n throw new Error(\n `Some changes have not been committed to Git:\n ${stdout}${\n onlyYarnLockModifiedOnDrone\n ? `\n\n The only file with changes is the yarn.lock file, indicating that npm was incorrectly used in addition to Yarn (eg. an \"npm install\" command was run). To fix this, force regeneration of the yarn.lock file locally with the following command and then commit the changes:\n\n ${commandExample('yarn --force')}`\n : ''\n }\n `,\n );\n }\n}\n","const CRLF = '\\r\\n';\n\nexport default function normalizeNewline(input: string) {\n if (typeof input !== 'string') {\n throw new TypeError(`Expected a \\`string\\`, got \\`${typeof input}\\``);\n }\n\n return input.replace(new RegExp(CRLF, 'g'), '\\n');\n}\n","import { execaCommand } from 'execa';\nimport normalizeNewline from '../util/normalizeNewline';\n\nexport const title = 'ESLint';\n\nexport default async function eslintCheck() {\n try {\n await execaCommand('yarn eslint . --max-warnings 0 --format compact');\n } catch (error) {\n const { stdout } = error as { stdout: string };\n const lines = stdout.split('\\n');\n\n // If no ESLint problems detected, throw the error\n if (!/^\\d+ problems?$/.test(lines[lines.length - 2])) {\n throw error;\n }\n\n throw new Error(\n `ESLint problems found in the following files:\n ${normalizeNewline(stdout)\n .split('\\n')\n // Match lines starting with slashes (macOS, Linux) or drive letters (Windows)\n .filter((line) => /^(\\/|[A-Z]:\\\\)/.test(line))\n // Strip out the filename\n .map((line) => line.match(/^(([A-Z]:)?[^:]+):/)?.[1])\n // Remove duplicate filenames\n .reduce((linesWithoutDuplicates: string[], line) => {\n if (line && !linesWithoutDuplicates.includes(line)) {\n linesWithoutDuplicates.push(line);\n }\n return linesWithoutDuplicates;\n }, [])\n .join('\\n')}\n\n Open these files in your editor - there should be problems to fix.\n `,\n );\n }\n}\n","import { promises as fs } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { execaCommand } from 'execa';\nimport readdirp from 'readdirp';\nimport semver from 'semver';\nimport commandExample from '../util/commandExample';\n\nconst require = createRequire(`${process.cwd()}/`);\n\nexport const title = 'ESLint config is latest version';\n\nexport default async function eslintConfigIsValid() {\n const { stdout: remoteVersion } = await execaCommand(\n 'npm show @upleveled/eslint-config-upleveled version',\n );\n\n let localVersion;\n\n try {\n const eslintConfigPackageJsonPath = require.resolve(\n '@upleveled/eslint-config-upleveled/package.json',\n );\n\n localVersion = JSON.parse(\n await fs.readFile(eslintConfigPackageJsonPath, 'utf-8'),\n ).version;\n } catch (err) {}\n\n if (typeof localVersion === 'undefined') {\n throw new Error(\n `The UpLeveled ESLint config has not been installed. Please install using the instructions on https://www.npmjs.com/package/@upleveled/eslint-config-upleveled\n `,\n );\n }\n\n if (semver.gt(remoteVersion, localVersion)) {\n throw new Error(\n `Your current version of the UpLeveled ESLint config (${localVersion}) is out of date. The latest version is ${remoteVersion}. Upgrade with:\n\n ${commandExample(\n 'yarn upgrade --latest @upleveled/eslint-config-upleveled',\n )}\n `,\n );\n }\n\n let eslintConfigMatches;\n\n try {\n eslintConfigMatches =\n (await fs.readFile('./.eslintrc.cjs', 'utf-8')).trim() ===\n `module.exports = {\n extends: ['@upleveled/upleveled'],\n};`;\n } catch (err) {\n throw new Error(\n `Error reading your .eslintrc.cjs file. Please reinstall the config using the instructions on https://www.npmjs.com/package/@upleveled/eslint-config-upleveled\n `,\n );\n }\n\n if (!eslintConfigMatches) {\n throw new Error(\n `Your ESLint config file .eslintrc.cjs does not match the configuration file template. Please reinstall the config using the instructions on https://www.npmjs.com/package/@upleveled/eslint-config-upleveled\n `,\n );\n }\n\n const eslintDisableOccurrences = [];\n\n for await (const { path } of readdirp('.', {\n directoryFilter: ['!.git', '!.next', '!node_modules'],\n fileFilter: ['*.js', '*.jsx', '*.ts', '*.tsx'],\n })) {\n const fileContents = await fs.readFile(path, 'utf-8');\n if (/eslint-disable|eslint [a-z0-9@/-]+: (0|off)/.test(fileContents)) {\n eslintDisableOccurrences.push(path);\n }\n }\n\n if (eslintDisableOccurrences.length > 0) {\n throw new Error(\n `ESLint has been disabled in the following files:\n ${eslintDisableOccurrences.join('\\n')}\n\n Remove all comments disabling or modifying ESLint rule configuration (eg. eslint-disable and eslint-disable-next-line comments) and fix the problems.\n `,\n );\n }\n}\n","import userAgents from 'top-user-agents';\n\nexport default function randomUserAgent() {\n const randomIndex = Math.floor(Math.random() * (userAgents.length - 1));\n return userAgents[randomIndex];\n}\n","import cheerio from 'cheerio';\nimport type { Element } from 'domhandler';\nimport { execaCommand } from 'execa';\nimport fetch from 'node-fetch';\nimport randomUserAgent from '../util/randomUserAgent';\n\nexport const title = 'GitHub repo has deployed project link under About';\n\nexport default async function linkOnGithubAbout() {\n const { stdout } = await execaCommand('git remote get-url origin');\n\n const repoUrl = stdout\n .replace('git@github.com:', 'https://github.com/')\n .replace('.git', '');\n\n const html = await (await fetch(repoUrl)).text();\n\n const $ = cheerio.load(html);\n\n const urlInAboutSection = $('h2')\n .filter(function (this: Element) {\n return $(this).text().trim() === 'About';\n })\n .nextAll('div')\n .filter(function (this: Element) {\n return $(this).children('.octicon.octicon-link').length > 0;\n })\n .children('.octicon.octicon-link')\n .next()\n .children('a[href]')\n .attr('href');\n\n if (!urlInAboutSection) {\n throw new Error(\n `Deployed project link not found in About section on ${repoUrl}. Click on the cog symbol to the right of the About heading and paste the Repl.it / Netlify / Heroku link in the Website box.`,\n );\n }\n\n const response = await fetch(urlInAboutSection, {\n headers: {\n // For repl.it\n 'user-agent': randomUserAgent(),\n },\n });\n\n if (!response.ok) {\n throw new Error(\n `Project link in About section on ${repoUrl} is not returning a proper status code: the link returns status code ${response.status} (${response.statusText}).`,\n );\n }\n}\n","import { promises as fs } from 'node:fs';\nimport { execaCommand } from 'execa';\nimport commandExample from '../util/commandExample';\nimport normalizeNewline from '../util/normalizeNewline';\n\nexport const title = 'node_modules/ folder ignored in Git';\n\nexport default async function nodeModulesIgnoredFromGit() {\n if ((await execaCommand('git ls-files node_modules/')).stdout !== '') {\n throw new Error(\n `node_modules/ folder committed to Git. Remove it using:\n\n ${commandExample('git rm -r --cached node_modules')}\n `,\n );\n }\n\n if ((await execaCommand('git ls-files .gitignore')).stdout !== '.gitignore') {\n throw new Error('.gitignore file not found');\n }\n\n const nodeModulesInGitignore = normalizeNewline(\n await fs.readFile('./.gitignore', 'utf8'),\n )\n .split('\\n')\n .reduce((found, line) => found || /^\\/?node_modules\\/?$/.test(line), false);\n\n if (!nodeModulesInGitignore) {\n throw new Error('node_modules not found in .gitignore');\n }\n}\n","import { existsSync, promises as fs } from 'node:fs';\nimport algoliasearch from 'algoliasearch';\nimport pReduce from 'p-reduce';\nimport commandExample from '../../util/commandExample';\n\nconst client = algoliasearch(\n // Application ID and API key specific to UpLeveled\n // Preflight. Please don't use anywhere else without\n // asking Algolia's permission.\n 'OFCNCOG2CU', // Application ID\n 'ec73550aa8b2936dab436d4e02144784', // API Key\n);\nconst index = client.initIndex('npm-search');\n\ninterface AlgoliaObj {\n types?: {\n definitelyTyped?: string;\n };\n}\n\nexport const title = 'No dependencies without types';\n\n// This is a naive check for matching @types/<pkg name> packages\n// that the student hasn't yet installed. It is not intended to\n// be an exhaustive check for any types for all packages.\n//\n// It attempts to address scenarios such as this with\n// `styled-components`:\n//\n// https://learn.upleveled.io/courses/btcmp-l-webfs-gen-0/modules/122-cheatsheet-css-in-js/#eslint-errors-with-styled-components\nexport default async function noDependenciesWithoutTypes() {\n const { devDependencies = {}, dependencies = {} } = JSON.parse(\n await fs.readFile('package.json', 'utf-8'),\n );\n\n const dependenciesWithMissingTypes = await pReduce(\n Object.keys(dependencies),\n async (filteredDependencies: [string, string][], dependency: string) => {\n try {\n const packageJsonPath = require.resolve(`${dependency}/package.json`);\n\n const modulePackageJson = JSON.parse(\n await fs.readFile(packageJsonPath, 'utf-8'),\n );\n\n // If the keys \"types\" or \"typings\" are in the module's `package.json`, bail out\n if ('types' in modulePackageJson || 'typings' in modulePackageJson) {\n return filteredDependencies;\n }\n } catch (err) {}\n\n let indexDTsPath;\n\n try {\n indexDTsPath = require.resolve(`${dependency}/index.d.ts`);\n } catch (err) {}\n\n // If the index.d.ts file exists inside the module's directory, bail out\n if (indexDTsPath && existsSync(indexDTsPath)) {\n return filteredDependencies;\n }\n\n const results = await index.getObject<AlgoliaObj>(dependency, {\n attributesToRetrieve: ['types'],\n });\n\n const definitelyTypedPackageName = results.types?.definitelyTyped;\n\n if (definitelyTypedPackageName) {\n // If a matching `@types/<package name>` has been already installed in devDependencies, bail out\n if (Object.keys(devDependencies).includes(definitelyTypedPackageName)) {\n return filteredDependencies;\n }\n\n filteredDependencies.push([dependency, definitelyTypedPackageName]);\n }\n\n return filteredDependencies;\n },\n [],\n );\n\n if (dependenciesWithMissingTypes.length > 0) {\n throw new Error(\n `Dependencies found without types. Add the missing types with:\n\n ${commandExample(\n `yarn add --dev ${dependenciesWithMissingTypes\n .map(([, definitelyTypedPackageName]) => definitelyTypedPackageName)\n .join(' ')}`,\n )}\n\n If the dependencies above are already in your package.json, check that they have not been incorrectly installed as regular dependencies in the \"dependencies\" object - they should be installed inside \"devDependencies\" (using the --dev flag mentioned above). To fix this situation, remove the dependencies and run the command above exactly.\n `,\n );\n }\n}\n","import { dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { execaCommand } from 'execa';\n\nconst { stdout: preflightBinPath } = await execaCommand(`yarn bin`, {\n cwd: dirname(fileURLToPath(import.meta.url)),\n});\n\nexport default preflightBinPath;\n","import { execaCommand } from 'execa';\nimport commandExample from '../../util/commandExample';\nimport preflightBinPath from '../../util/preflightBinPath';\n\nexport const title = 'No unused dependencies';\n\nexport default async function noUnusedAndMissingDependencies() {\n const ignoredPackagePatterns = [\n // Unused dependency detected in https://github.com/upleveled/next-portfolio-dev\n '@graphql-codegen/cli',\n\n // Unused dependency detected in create-react-app\n '@testing-library/jest-dom',\n '@testing-library/react',\n '@testing-library/user-event',\n 'react-scripts',\n 'web-vitals',\n\n // Tailwind CSS\n '@tailwindcss/jit',\n 'autoprefixer',\n 'postcss',\n 'tailwindcss',\n\n // ESLint configuration\n '@babel/eslint-parser',\n '@next/eslint-plugin-next',\n '@typescript-eslint/*',\n '@upleveled/eslint-config-upleveled',\n '@upleveled/eslint-plugin-upleveled',\n 'babel-eslint',\n 'eslint',\n 'eslint-config-next',\n 'eslint-config-react-app',\n 'eslint-import-resolver-typescript',\n 'eslint-plugin-*',\n\n // Testing\n 'babel-jest',\n 'jest',\n 'cypress',\n\n // TypeScript\n 'typescript',\n '@types/*',\n\n // Next.js\n 'sharp',\n ].join(',');\n\n try {\n await execaCommand(\n `${preflightBinPath}/depcheck --ignores=\"${ignoredPackagePatterns}\"`,\n );\n } catch (error) {\n const { stdout } = error as { stdout: string };\n if (\n !stdout.startsWith('Unused dependencies') &&\n !stdout.startsWith('Unused devDependencies') &&\n !stdout.startsWith('Missing dependencies')\n ) {\n throw error;\n }\n\n const [unusedDependenciesStdout, missingDependenciesStdout] = stdout.split(\n 'Missing dependencies',\n );\n\n const messages = [];\n\n if (unusedDependenciesStdout) {\n messages.push(`Unused dependencies found:\n ${unusedDependenciesStdout\n .split('\\n')\n .filter((str: string) => str.includes('* '))\n .join('\\n')}\n\n Remove these dependencies by running the following command for each dependency:\n\n ${commandExample('yarn remove <dependency name here>')}\n `);\n }\n\n if (missingDependenciesStdout) {\n messages.push(`Missing dependencies found:\n ${missingDependenciesStdout\n .split('\\n')\n .filter((str: string) => str.includes('* '))\n .join('\\n')}\n\n Add these missing dependencies by running the following command for each dependency:\n\n ${commandExample('yarn add <dependency name here>')}\n `);\n }\n\n throw new Error(messages.join('\\n\\n'));\n }\n}\n","import { execaCommand } from 'execa';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'No extraneous files committed to Git';\n\nexport default async function noExtraneousFilesCommittedToGit() {\n const { stdout } = await execaCommand(\n 'git ls-files .DS_Store yarn-error.log npm-debug.log',\n );\n\n if (stdout !== '') {\n throw new Error(\n `Extraneous files committed to Git:\n ${stdout}\n\n Remove these files from your repo by running the following command for each file:\n\n ${commandExample('git rm --cached <filename here>')}\n\n Once you've removed all files, make sure that it doesn't happen again by adding the filenames above to your .gitignore file.\n `,\n );\n }\n}\n","import { execaCommand } from 'execa';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'No secrets committed to Git';\n\nexport default async function noSecretsCommittedToGit() {\n const { stdout } = await execaCommand('git ls-files .env .env*.local');\n\n if (stdout !== '') {\n throw new Error(\n `Secrets committed to Git 😱:\n ${stdout}\n\n Remove these files from your repo by installing BFG from the System Setup Guide (see Optional Software at the bottom) and running it on each of your files like this:\n\n ${commandExample('bfg --delete-files <filename here>')}\n\n Once you've done this for every secret file, then force push to your repository:\n\n ${commandExample('git push --force')}\n\n More info: https://docs.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository\n\n Finally, make sure that this doesn't happen again by adding the filenames above to your .gitignore file.\n `,\n );\n }\n}\n","import { promises as fs } from 'node:fs';\nimport os from 'node:os';\nimport { URL } from 'node:url';\nimport { execaCommand } from 'execa';\nimport semver from 'semver';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'Preflight is latest version';\n\nexport default async function preflightIsLatestVersion() {\n const { stdout: remoteVersion } = await execaCommand(\n 'npm show @upleveled/preflight version',\n );\n\n const localVersion = JSON.parse(\n await fs.readFile(new URL('../package.json', import.meta.url), 'utf-8'),\n ).version;\n\n if (semver.gt(remoteVersion, localVersion)) {\n throw new Error(\n `Your current version of Preflight (${localVersion}) is out of date. The latest version is ${remoteVersion}. Upgrade with:\n\n ${commandExample(\n `${\n os.platform() === 'linux' ? 'sudo ' : ''\n }yarn global add @upleveled/preflight`,\n )}\n `,\n );\n }\n}\n","import { dirname } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { execaCommand } from 'execa';\nimport normalizeNewline from '../util/normalizeNewline';\n\nexport const title = 'Prettier';\n\nexport default async function prettierCheck() {\n try {\n await execaCommand(\n `yarn --silent prettier --list-different ${process.cwd()}/**/*.{js,jsx,ts,jsx} --ignore-path ${process.cwd()}/.eslintignore --config ${process.cwd()}/prettier.config.cjs --end-of-line auto`,\n { cwd: dirname(fileURLToPath(import.meta.url)) },\n );\n } catch (error) {\n const { stdout, stderr } = error as { stdout: string; stderr: string };\n\n const stderrWithoutPackageJsonWarning = stderr.replace(\n /warning [/.\\\\]*package\\.json: No license field[\\r\\n]*/g,\n '',\n );\n\n if (!stdout || stderrWithoutPackageJsonWarning) {\n throw error;\n }\n\n const ignoredFilePatterns = [\n // File from create-react-app not matching our formatting\n // https://github.com/facebook/create-react-app/blob/fdbde1f3c256b43d5386b5ae3a75083dbd8f0aff/packages/cra-template/template/src/reportWebVitals.js\n /src[/\\\\]reportWebVitals\\.js$/,\n\n // Files from create-next-app not matching our formatting\n // https://github.com/vercel/next.js/blob/5a73859fe8d3659d52e169f97188ae422e0d2ace/packages/create-next-app/templates/default/pages/api/hello.js\n /pages[/\\\\]api[/\\\\]hello\\.js$/,\n // https://github.com/vercel/next.js/blob/aacfa79ddf88e4e1488b63ac253af27110f0a151/packages/create-next-app/templates/default/pages/_app.js\n /pages[/\\\\]_app\\.js$/,\n ];\n\n const unformattedFiles = normalizeNewline(stdout)\n .split('\\n')\n .map((file) =>\n // Make paths relative to the project instead of Preflight, eg:\n // before: ../../../../../../projects/random-color-generator-react-app/src/reportWebVitals.js\n // after: random-color-generator-react-app/src/reportWebVitals.js\n file.replace(/^([A-Z]:|\\.\\.[/\\\\])[a-zA-Z0-9-_/.\\\\ ]*projects[/\\\\]/, ''),\n )\n .filter(\n (file) =>\n !ignoredFilePatterns.some((ignoredFilePattern) =>\n ignoredFilePattern.test(file),\n ),\n );\n\n if (unformattedFiles.length > 0) {\n throw new Error(\n `Prettier has not been run in the following files:\n ${unformattedFiles.join('\\n')}\n\n First, try opening the files above in your editor and saving them. This should format the file with Prettier.\n\n If the code in these files has already been formatted by Prettier, in very seldom cases, the mismatch may come from inconsistent end of line characters.\n\n Fix this in VS Code like this:\n\n 1. cmd/ctrl-shift-P -> Change End of Line Sequence -> CRLF\n 2. Save the file\n 3. cmd/ctrl-shift-P -> Change End of Line Sequence -> LF\n 4. Save the file\n `,\n );\n }\n }\n}\n","import path from 'node:path';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'Project folder name matches correct format';\n\nexport default function projectFolderNameMatchesCorrectFormat() {\n const currentDirectoryName = path.basename(process.cwd());\n const lowercaseHyphenedDirectoryName = currentDirectoryName\n .toLowerCase()\n .replaceAll(' ', '-');\n\n if (currentDirectoryName !== lowercaseHyphenedDirectoryName) {\n throw new Error(\n `Project directory name \"${currentDirectoryName}\" doesn't match the correct format (no spaces or uppercase letters).\n\n Rename the directory to the correct name \"${lowercaseHyphenedDirectoryName}\" with the following sequence of commands:\n\n ${commandExample('cd ..')}\n ${commandExample(\n `mv ${currentDirectoryName} ${lowercaseHyphenedDirectoryName}`,\n )}\n ${commandExample(`cd ${lowercaseHyphenedDirectoryName}`)}\n `,\n );\n }\n}\n","import { execaCommand } from 'execa';\nimport commandExample from '../util/commandExample';\n\nexport const title = 'Use single package manager';\n\nexport default async function useSinglePackageManager() {\n const { stdout } = await execaCommand('git ls-files package-lock.json');\n\n if (stdout !== '') {\n throw new Error(\n `package-lock.json file committed to Git. Remove it with:\n\n ${commandExample('git rm --cached <filename>')}\n\n After you've removed it, you can delete the file with:\n\n ${commandExample('rm <filename>')}\n\n The presence of this file indicates that npm was incorrectly used in addition to Yarn (eg. an \"npm install\" command was run). In order to avoid issues with the state of the yarn.lock file, we suggest also forcing regeneration this file with the following command:\n\n ${commandExample('yarn --force')}\n `,\n );\n }\n}\n","import { promises as fs } from 'node:fs';\nimport { URL } from 'node:url';\nimport { Listr } from 'listr2';\nimport * as allChangesCommittedToGit from './checks/allChangesCommittedToGit.js';\nimport * as eslint from './checks/eslint.js';\nimport * as eslintConfigIsValid from './checks/eslintConfigIsValid.js';\nimport * as linkOnGithubAbout from './checks/linkOnGithubAbout.js';\nimport * as nodeModulesIgnoredFromGit from './checks/nodeModulesIgnoredFromGit.js';\nimport * as noDependenciesWithoutTypes from './checks/noDependencyProblems/noDependenciesWithoutTypes.js';\nimport * as noUnusedAndMissingDependencies from './checks/noDependencyProblems/noUnusedDependencies.js';\nimport * as noExtraneousFilesCommittedToGit from './checks/noExtraneousFilesCommittedToGit.js';\nimport * as noSecretsCommittedToGit from './checks/noSecretsCommittedToGit.js';\nimport * as preflightIsLatestVersion from './checks/preflightIsLatestVersion.js';\nimport * as prettier from './checks/prettier.js';\nimport * as projectFolderNameMatchesCorrectFormat from './checks/projectFolderNameMatchesCorrectFormat.js';\nimport * as useSinglePackageManager from './checks/useSinglePackageManager.js';\nimport { CtxParam } from './types/CtxParam.js';\nimport { TaskParam } from './types/TaskParam.js';\n\nconst version = JSON.parse(\n await fs.readFile(new URL('../package.json', import.meta.url), 'utf-8'),\n).version;\n\nconsole.log(`🚀 UpLeveled Preflight v${version}`);\n\nconst listrTasks = [\n // ======= Sync Tasks =======\n // Git\n allChangesCommittedToGit,\n nodeModulesIgnoredFromGit,\n noExtraneousFilesCommittedToGit,\n noSecretsCommittedToGit,\n\n // Package managers\n useSinglePackageManager,\n\n // Project setup\n projectFolderNameMatchesCorrectFormat,\n\n // ======= Async Tasks =======\n // Dependencies\n {\n title: 'No dependency problems',\n task: (ctx: CtxParam, task: TaskParam): Listr =>\n task.newListr([\n {\n title: noUnusedAndMissingDependencies.title,\n task: noUnusedAndMissingDependencies.default,\n },\n {\n title: noDependenciesWithoutTypes.title,\n task: noDependenciesWithoutTypes.default,\n },\n ]),\n },\n\n // GitHub\n linkOnGithubAbout,\n\n // Linting\n eslint,\n prettier,\n\n // Version and configuration checks\n eslintConfigIsValid,\n preflightIsLatestVersion,\n].map((module) => {\n if ('task' in module) return module;\n return {\n title: module.title,\n task: module.default,\n };\n});\n\nawait new Listr(listrTasks, {\n exitOnError: false,\n rendererOptions: {\n collapseErrors: false,\n removeEmptyLines: false,\n formatOutput: 'wrap',\n },\n concurrent: 5,\n}).run();\n"],"names":["emptyBrailleCharacter","commandExample","command","chalk","dim","isDrone","stdout","execaCommand","reject","test","title","allChangesCommittedToGit","replSlug","isRunningInReplIt","fs","writeFile","onlyYarnLockModifiedOnDrone","trim","Error","CRLF","normalizeNewline","input","TypeError","replace","RegExp","eslintCheck","error","lines","split","length","filter","line","map","match","reduce","linesWithoutDuplicates","includes","push","join","require","createRequire","process","cwd","eslintConfigIsValid","remoteVersion","localVersion","eslintConfigPackageJsonPath","resolve","JSON","parse","readFile","version","err","semver","gt","eslintConfigMatches","eslintDisableOccurrences","path","readdirp","directoryFilter","fileFilter","fileContents","randomUserAgent","randomIndex","Math","floor","random","userAgents","linkOnGithubAbout","repoUrl","html","fetch","text","$","cheerio","load","urlInAboutSection","nextAll","children","next","attr","response","headers","ok","status","statusText","nodeModulesIgnoredFromGit","nodeModulesInGitignore","found","client","algoliasearch","index","initIndex","noDependenciesWithoutTypes","devDependencies","dependencies","dependenciesWithMissingTypes","pReduce","Object","keys","filteredDependencies","dependency","packageJsonPath","modulePackageJson","indexDTsPath","existsSync","results","getObject","attributesToRetrieve","definitelyTypedPackageName","types","definitelyTyped","preflightBinPath","dirname","fileURLToPath","import","meta","url","noUnusedAndMissingDependencies","ignoredPackagePatterns","startsWith","unusedDependenciesStdout","missingDependenciesStdout","messages","str","noExtraneousFilesCommittedToGit","noSecretsCommittedToGit","preflightIsLatestVersion","URL","os","platform","prettierCheck","stderr","stderrWithoutPackageJsonWarning","ignoredFilePatterns","unformattedFiles","file","some","ignoredFilePattern","projectFolderNameMatchesCorrectFormat","currentDirectoryName","basename","lowercaseHyphenedDirectoryName","toLowerCase","replaceAll","useSinglePackageManager","console","log","listrTasks","task","ctx","newListr","eslint","prettier","module","default","Listr","exitOnError","rendererOptions","collapseErrors","removeEmptyLines","formatOutput","concurrent","run"],"mappings":";;;;;;;;;;;;;;;;AAGA,MAAMA,qBAAqB,GAAG,GAA9B;SAEwBC,eAAeC;AACrC,YAAUF,0BAA0BG,KAAK,CAACC,GAAN,CAAU,GAAV,KAAkBF,SAAtD;AACD;;ACLM,eAAeG,OAAf;AACL,QAAM;AAAEC,IAAAA;AAAF,MAAa,MAAMC,YAAY,CAAC,qBAAD,EAAwB;AAC3DC,IAAAA,MAAM,EAAE;AADmD,GAAxB,CAArC;AAGA,SAAO,eAAeC,IAAf,CAAoBH,MAApB,CAAP;AACD;;ACFM,MAAMI,KAAK,GAAG,8BAAd;AAEP,AAAe,eAAeC,wBAAf;AACb,QAAM;AAAEL,IAAAA,MAAM,EAAEM;AAAV,MAAuB,MAAML,YAAY,CAAC,iBAAD,CAA/C;AAEA,QAAMM,iBAAiB,GAAGD,QAAQ,KAAK,EAAvC;;AAEA,MAAIC,iBAAJ,EAAuB;AACrB,UAAMC,QAAE,CAACC,SAAH,CAAa,mBAAb,EAAkC,WAAlC,CAAN;AACD;;AAED,QAAM;AAAET,IAAAA;AAAF,MAAa,MAAMC,YAAY,CAAC,wBAAD,CA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|
1
|
-
import { ListrTaskWrapper } from 'listr2';
|
|
2
|
-
|
|
3
|
-
export declare type TaskParam = ListrTaskWrapper<any, typeof DefaultRenderer>;
|
|
1
|
+
import { ListrDefaultRenderer, ListrTaskWrapper } from 'listr2';
|
|
2
|
+
export declare type TaskParam = ListrTaskWrapper<any, ListrDefaultRenderer>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upleveled/preflight",
|
|
3
|
-
"version": "1.18.
|
|
3
|
+
"version": "1.18.8",
|
|
4
4
|
"author": "UpLeveled (https://github.com/upleveled)",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"José Fernando Höwer Barbosa <josehowerupn@gmail.com>",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"build": "tsdx build --format esm --target node",
|
|
29
29
|
"test": "tsdx test",
|
|
30
30
|
"test-local": "rm -rf ./__tests__/fixtures/__temp && yarn test",
|
|
31
|
-
"lint": "
|
|
31
|
+
"lint": "eslint . --max-warnings 0",
|
|
32
32
|
"prepare": "yarn build",
|
|
33
33
|
"size": "size-limit",
|
|
34
34
|
"analyze": "size-limit --why",
|
|
@@ -36,57 +36,64 @@
|
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@babel/plugin-transform-modules-commonjs": "7.
|
|
40
|
-
"@next/eslint-plugin-next": "
|
|
41
|
-
"@size-limit/
|
|
42
|
-
"@types/node": "
|
|
39
|
+
"@babel/plugin-transform-modules-commonjs": "7.16.7",
|
|
40
|
+
"@next/eslint-plugin-next": "12.0.7",
|
|
41
|
+
"@size-limit/file": "7.0.5",
|
|
42
|
+
"@types/node": "17.0.8",
|
|
43
43
|
"@types/p-map": "2.0.0",
|
|
44
|
-
"@types/semver": "7.3.
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "
|
|
46
|
-
"@typescript-eslint/parser": "
|
|
47
|
-
"@upleveled/eslint-config-upleveled": "1.
|
|
48
|
-
"@upleveled/eslint-plugin-upleveled": "
|
|
44
|
+
"@types/semver": "7.3.9",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "5.9.0",
|
|
46
|
+
"@typescript-eslint/parser": "5.9.0",
|
|
47
|
+
"@upleveled/eslint-config-upleveled": "2.1.7",
|
|
48
|
+
"@upleveled/eslint-plugin-upleveled": "2.0.1",
|
|
49
49
|
"babel-eslint": "10.1.0",
|
|
50
|
-
"
|
|
51
|
-
"eslint
|
|
50
|
+
"babel-jest": "27.4.6",
|
|
51
|
+
"eslint": "8.6.0",
|
|
52
|
+
"eslint-config-react-app": "7.0.0",
|
|
52
53
|
"eslint-import-resolver-typescript": "2.5.0",
|
|
53
54
|
"eslint-plugin-cypress": "2.12.1",
|
|
54
|
-
"eslint-plugin-flowtype": "
|
|
55
|
-
"eslint-plugin-import": "2.
|
|
56
|
-
"eslint-plugin-jest": "
|
|
57
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
55
|
+
"eslint-plugin-flowtype": "8.0.3",
|
|
56
|
+
"eslint-plugin-import": "2.25.4",
|
|
57
|
+
"eslint-plugin-jest": "25.3.4",
|
|
58
|
+
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
58
59
|
"eslint-plugin-prettier": "4.0.0",
|
|
59
|
-
"eslint-plugin-react": "7.
|
|
60
|
-
"eslint-plugin-react-hooks": "4.
|
|
61
|
-
"eslint-plugin-testing-library": "
|
|
62
|
-
"eslint-plugin-unicorn": "
|
|
63
|
-
"p-map": "5.
|
|
64
|
-
"size-limit": "
|
|
60
|
+
"eslint-plugin-react": "7.28.0",
|
|
61
|
+
"eslint-plugin-react-hooks": "4.3.0",
|
|
62
|
+
"eslint-plugin-testing-library": "5.0.1",
|
|
63
|
+
"eslint-plugin-unicorn": "40.0.0",
|
|
64
|
+
"p-map": "5.3.0",
|
|
65
|
+
"size-limit": "7.0.5",
|
|
65
66
|
"tsdx": "0.14.1",
|
|
66
67
|
"tslib": "2.3.1",
|
|
67
|
-
"typescript": "4.4
|
|
68
|
+
"typescript": "4.5.4"
|
|
68
69
|
},
|
|
69
70
|
"dependencies": {
|
|
70
|
-
"algoliasearch": "4.
|
|
71
|
-
"chalk": "
|
|
71
|
+
"algoliasearch": "4.12.0",
|
|
72
|
+
"chalk": "5.0.0",
|
|
72
73
|
"cheerio": "1.0.0-rc.10",
|
|
73
74
|
"depcheck": "1.4.2",
|
|
74
|
-
"execa": "
|
|
75
|
-
"listr2": "
|
|
76
|
-
"node-fetch": "3.
|
|
75
|
+
"execa": "6.0.0",
|
|
76
|
+
"listr2": "4.0.0",
|
|
77
|
+
"node-fetch": "3.1.0",
|
|
77
78
|
"p-reduce": "3.0.0",
|
|
78
|
-
"prettier": "2.
|
|
79
|
+
"prettier": "2.5.1",
|
|
79
80
|
"readdirp": "3.6.0",
|
|
80
81
|
"semver": "7.3.5",
|
|
81
|
-
"top-user-agents": "1.0.
|
|
82
|
+
"top-user-agents": "1.0.40"
|
|
82
83
|
},
|
|
83
84
|
"resolutions": {
|
|
84
85
|
"tsdx/**/node-notifier": "10.0.0",
|
|
85
|
-
"
|
|
86
|
+
"tsdx/jest": "27.4.7",
|
|
87
|
+
"tsdx/ts-jest": "27.1.2",
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "5.9.0",
|
|
89
|
+
"@typescript-eslint/parser": "5.9.0",
|
|
90
|
+
"eslint": "8.6.0",
|
|
91
|
+
"eslint-plugin-import": "2.25.4",
|
|
92
|
+
"eslint-plugin-react": "7.28.0"
|
|
86
93
|
},
|
|
87
94
|
"jest": {
|
|
88
95
|
"transformIgnorePatterns": [
|
|
89
|
-
"[/\\\\]node_modules[/\\\\](?!aggregate-error|clean-stack|escape-string-regexp|indent-string|p-map).+\\.(js|jsx)$"
|
|
96
|
+
"[/\\\\]node_modules[/\\\\](?!aggregate-error|clean-stack|escape-string-regexp|execa|human-signals|indent-string|is-stream|mimic-fn|npm-run-path|onetime|p-map|path-key|strip-final-newline).+\\.(js|jsx)$"
|
|
90
97
|
]
|
|
91
98
|
}
|
|
92
99
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
|
-
import
|
|
2
|
+
import { execaCommand } from 'execa';
|
|
3
3
|
import commandExample from '../util/commandExample';
|
|
4
4
|
import { isDrone } from '../util/isDrone';
|
|
5
5
|
|
|
6
6
|
export const title = 'All changes committed to Git';
|
|
7
7
|
|
|
8
8
|
export default async function allChangesCommittedToGit() {
|
|
9
|
-
const { stdout: replSlug } = await
|
|
9
|
+
const { stdout: replSlug } = await execaCommand('echo $REPL_SLUG');
|
|
10
10
|
|
|
11
11
|
const isRunningInReplIt = replSlug !== '';
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ export default async function allChangesCommittedToGit() {
|
|
|
14
14
|
await fs.writeFile('.git/info/exclude', '.replit\n');
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const { stdout } = await
|
|
17
|
+
const { stdout } = await execaCommand('git status --porcelain');
|
|
18
18
|
|
|
19
19
|
if (stdout !== '') {
|
|
20
20
|
const onlyYarnLockModifiedOnDrone =
|
package/src/checks/eslint.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
2
|
import normalizeNewline from '../util/normalizeNewline';
|
|
3
3
|
|
|
4
4
|
export const title = 'ESLint';
|
|
5
5
|
|
|
6
6
|
export default async function eslintCheck() {
|
|
7
7
|
try {
|
|
8
|
-
await
|
|
8
|
+
await execaCommand('yarn eslint . --max-warnings 0 --format compact');
|
|
9
9
|
} catch (error) {
|
|
10
10
|
const { stdout } = error as { stdout: string };
|
|
11
11
|
const lines = stdout.split('\n');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import
|
|
3
|
+
import { execaCommand } from 'execa';
|
|
4
4
|
import readdirp from 'readdirp';
|
|
5
5
|
import semver from 'semver';
|
|
6
6
|
import commandExample from '../util/commandExample';
|
|
@@ -10,7 +10,7 @@ const require = createRequire(`${process.cwd()}/`);
|
|
|
10
10
|
export const title = 'ESLint config is latest version';
|
|
11
11
|
|
|
12
12
|
export default async function eslintConfigIsValid() {
|
|
13
|
-
const { stdout: remoteVersion } = await
|
|
13
|
+
const { stdout: remoteVersion } = await execaCommand(
|
|
14
14
|
'npm show @upleveled/eslint-config-upleveled version',
|
|
15
15
|
);
|
|
16
16
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import cheerio from 'cheerio';
|
|
2
2
|
import type { Element } from 'domhandler';
|
|
3
|
-
import
|
|
3
|
+
import { execaCommand } from 'execa';
|
|
4
4
|
import fetch from 'node-fetch';
|
|
5
5
|
import randomUserAgent from '../util/randomUserAgent';
|
|
6
6
|
|
|
7
7
|
export const title = 'GitHub repo has deployed project link under About';
|
|
8
8
|
|
|
9
9
|
export default async function linkOnGithubAbout() {
|
|
10
|
-
const { stdout } = await
|
|
10
|
+
const { stdout } = await execaCommand('git remote get-url origin');
|
|
11
11
|
|
|
12
12
|
const repoUrl = stdout
|
|
13
13
|
.replace('git@github.com:', 'https://github.com/')
|
|
@@ -89,6 +89,8 @@ export default async function noDependenciesWithoutTypes() {
|
|
|
89
89
|
.map(([, definitelyTypedPackageName]) => definitelyTypedPackageName)
|
|
90
90
|
.join(' ')}`,
|
|
91
91
|
)}
|
|
92
|
+
|
|
93
|
+
If the dependencies above are already in your package.json, check that they have not been incorrectly installed as regular dependencies in the "dependencies" object - they should be installed inside "devDependencies" (using the --dev flag mentioned above). To fix this situation, remove the dependencies and run the command above exactly.
|
|
92
94
|
`,
|
|
93
95
|
);
|
|
94
96
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
2
|
import commandExample from '../../util/commandExample';
|
|
3
3
|
import preflightBinPath from '../../util/preflightBinPath';
|
|
4
4
|
|
|
@@ -6,6 +6,9 @@ export const title = 'No unused dependencies';
|
|
|
6
6
|
|
|
7
7
|
export default async function noUnusedAndMissingDependencies() {
|
|
8
8
|
const ignoredPackagePatterns = [
|
|
9
|
+
// Unused dependency detected in https://github.com/upleveled/next-portfolio-dev
|
|
10
|
+
'@graphql-codegen/cli',
|
|
11
|
+
|
|
9
12
|
// Unused dependency detected in create-react-app
|
|
10
13
|
'@testing-library/jest-dom',
|
|
11
14
|
'@testing-library/react',
|
|
@@ -46,7 +49,7 @@ export default async function noUnusedAndMissingDependencies() {
|
|
|
46
49
|
].join(',');
|
|
47
50
|
|
|
48
51
|
try {
|
|
49
|
-
await
|
|
52
|
+
await execaCommand(
|
|
50
53
|
`${preflightBinPath}/depcheck --ignores="${ignoredPackagePatterns}"`,
|
|
51
54
|
);
|
|
52
55
|
} catch (error) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
2
|
import commandExample from '../util/commandExample';
|
|
3
3
|
|
|
4
4
|
export const title = 'No extraneous files committed to Git';
|
|
5
5
|
|
|
6
6
|
export default async function noExtraneousFilesCommittedToGit() {
|
|
7
|
-
const { stdout } = await
|
|
7
|
+
const { stdout } = await execaCommand(
|
|
8
8
|
'git ls-files .DS_Store yarn-error.log npm-debug.log',
|
|
9
9
|
);
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
2
|
import commandExample from '../util/commandExample';
|
|
3
3
|
|
|
4
4
|
export const title = 'No secrets committed to Git';
|
|
5
5
|
|
|
6
6
|
export default async function noSecretsCommittedToGit() {
|
|
7
|
-
const { stdout } = await
|
|
7
|
+
const { stdout } = await execaCommand('git ls-files .env .env*.local');
|
|
8
8
|
|
|
9
9
|
if (stdout !== '') {
|
|
10
10
|
throw new Error(
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
|
-
import
|
|
2
|
+
import { execaCommand } from 'execa';
|
|
3
3
|
import commandExample from '../util/commandExample';
|
|
4
4
|
import normalizeNewline from '../util/normalizeNewline';
|
|
5
5
|
|
|
6
6
|
export const title = 'node_modules/ folder ignored in Git';
|
|
7
7
|
|
|
8
8
|
export default async function nodeModulesIgnoredFromGit() {
|
|
9
|
-
if ((await
|
|
9
|
+
if ((await execaCommand('git ls-files node_modules/')).stdout !== '') {
|
|
10
10
|
throw new Error(
|
|
11
11
|
`node_modules/ folder committed to Git. Remove it using:
|
|
12
12
|
|
|
@@ -15,9 +15,7 @@ export default async function nodeModulesIgnoredFromGit() {
|
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
if (
|
|
19
|
-
(await execa.command('git ls-files .gitignore')).stdout !== '.gitignore'
|
|
20
|
-
) {
|
|
18
|
+
if ((await execaCommand('git ls-files .gitignore')).stdout !== '.gitignore') {
|
|
21
19
|
throw new Error('.gitignore file not found');
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import { URL } from 'node:url';
|
|
4
|
-
import
|
|
4
|
+
import { execaCommand } from 'execa';
|
|
5
5
|
import semver from 'semver';
|
|
6
6
|
import commandExample from '../util/commandExample';
|
|
7
7
|
|
|
8
8
|
export const title = 'Preflight is latest version';
|
|
9
9
|
|
|
10
10
|
export default async function preflightIsLatestVersion() {
|
|
11
|
-
const { stdout: remoteVersion } = await
|
|
11
|
+
const { stdout: remoteVersion } = await execaCommand(
|
|
12
12
|
'npm show @upleveled/preflight version',
|
|
13
13
|
);
|
|
14
14
|
|
package/src/checks/prettier.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { dirname } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import
|
|
3
|
+
import { execaCommand } from 'execa';
|
|
4
4
|
import normalizeNewline from '../util/normalizeNewline';
|
|
5
5
|
|
|
6
6
|
export const title = 'Prettier';
|
|
7
7
|
|
|
8
8
|
export default async function prettierCheck() {
|
|
9
9
|
try {
|
|
10
|
-
await
|
|
10
|
+
await execaCommand(
|
|
11
11
|
`yarn --silent prettier --list-different ${process.cwd()}/**/*.{js,jsx,ts,jsx} --ignore-path ${process.cwd()}/.eslintignore --config ${process.cwd()}/prettier.config.cjs --end-of-line auto`,
|
|
12
12
|
{ cwd: dirname(fileURLToPath(import.meta.url)) },
|
|
13
13
|
);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
2
|
import commandExample from '../util/commandExample';
|
|
3
3
|
|
|
4
4
|
export const title = 'Use single package manager';
|
|
5
5
|
|
|
6
6
|
export default async function useSinglePackageManager() {
|
|
7
|
-
const { stdout } = await
|
|
7
|
+
const { stdout } = await execaCommand('git ls-files package-lock.json');
|
|
8
8
|
|
|
9
9
|
if (stdout !== '') {
|
|
10
10
|
throw new Error(
|
package/src/types/TaskParam.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ListrTaskWrapper } from 'listr2';
|
|
2
|
-
import { DefaultRenderer } from 'listr2/dist/renderer/default.renderer';
|
|
1
|
+
import { ListrDefaultRenderer, ListrTaskWrapper } from 'listr2';
|
|
3
2
|
|
|
4
|
-
export type TaskParam = ListrTaskWrapper<any,
|
|
3
|
+
export type TaskParam = ListrTaskWrapper<any, ListrDefaultRenderer>;
|
package/src/util/isDrone.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { execaCommand } from 'execa';
|
|
2
2
|
|
|
3
3
|
export async function isDrone() {
|
|
4
|
-
const { stdout } = await
|
|
4
|
+
const { stdout } = await execaCommand('cat /etc/os-release', {
|
|
5
5
|
reject: false,
|
|
6
6
|
});
|
|
7
7
|
return /Alpine Linux/.test(stdout);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { dirname } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import
|
|
3
|
+
import { execaCommand } from 'execa';
|
|
4
4
|
|
|
5
|
-
const { stdout: preflightBinPath } = await
|
|
5
|
+
const { stdout: preflightBinPath } = await execaCommand(`yarn bin`, {
|
|
6
6
|
cwd: dirname(fileURLToPath(import.meta.url)),
|
|
7
7
|
});
|
|
8
8
|
|