@upleveled/preflight 7.0.3 → 7.0.5
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 +70 -64
- package/dist/preflight.esm.js.map +1 -1
- package/package.json +12 -12
- package/src/checks/allChangesCommittedToGit.ts +3 -3
- package/src/checks/eslint.ts +7 -3
- package/src/checks/eslintConfigIsValid.ts +7 -6
- package/src/checks/linkOnGithubAbout.ts +2 -2
- package/src/checks/noDependencyProblems/noDependenciesWithoutTypes.ts +6 -2
- package/src/checks/noDependencyProblems/noUnusedDependencies.ts +2 -4
- package/src/checks/noExtraneousFilesCommittedToGit.ts +3 -4
- package/src/checks/noSecretsCommittedToGit.ts +2 -2
- package/src/checks/nodeModulesIgnoredFromGit.ts +3 -3
- package/src/checks/preflightIsLatestVersion.ts +3 -4
- package/src/checks/prettier.ts +6 -4
- package/src/checks/stylelint.ts +9 -7
- package/src/checks/stylelintConfigIsValid.ts +7 -6
- package/src/checks/useSinglePackageManager.ts +2 -4
- package/src/index.ts +0 -9
- package/src/util/drone.ts +3 -3
- package/src/util/preflightBinPath.ts +3 -3
- package/dist/checks/noDependencyProblems/nextJsProjectHasSharpInstalled.d.ts +0 -2
- package/src/checks/noDependencyProblems/nextJsProjectHasSharpInstalled.ts +0 -21
package/dist/preflight.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Listr } from 'listr2';
|
|
2
2
|
import { promises, existsSync } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { execa } from 'execa';
|
|
4
4
|
import chalk from 'chalk';
|
|
5
5
|
import path, { sep, dirname } from 'node:path';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
@@ -9,9 +9,9 @@ import semver from 'semver';
|
|
|
9
9
|
import cheerio from 'cheerio';
|
|
10
10
|
import fetch from 'node-fetch';
|
|
11
11
|
import userAgents from 'top-user-agents';
|
|
12
|
-
import { URL, fileURLToPath } from 'node:url';
|
|
13
12
|
import algoliasearch from 'algoliasearch';
|
|
14
13
|
import pReduce from 'p-reduce';
|
|
14
|
+
import { URL, fileURLToPath } from 'node:url';
|
|
15
15
|
import os from 'node:os';
|
|
16
16
|
|
|
17
17
|
// https://www.compart.com/en/unicode/U+2800
|
|
@@ -24,9 +24,9 @@ function commandExample(command) {
|
|
|
24
24
|
async function isDrone() {
|
|
25
25
|
const {
|
|
26
26
|
stdout
|
|
27
|
-
} = await
|
|
27
|
+
} = await execa({
|
|
28
28
|
reject: false
|
|
29
|
-
})
|
|
29
|
+
})`cat /etc/os-release`;
|
|
30
30
|
return /Alpine Linux/.test(stdout);
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -34,14 +34,14 @@ const title = 'All changes committed to Git';
|
|
|
34
34
|
async function allChangesCommittedToGit() {
|
|
35
35
|
const {
|
|
36
36
|
stdout: replSlug
|
|
37
|
-
} = await
|
|
37
|
+
} = await execa`echo $REPL_SLUG`;
|
|
38
38
|
const isRunningInReplIt = replSlug !== '';
|
|
39
39
|
if (isRunningInReplIt) {
|
|
40
40
|
await promises.writeFile('.git/info/exclude', '.replit\n');
|
|
41
41
|
}
|
|
42
42
|
const {
|
|
43
43
|
stdout
|
|
44
|
-
} = await
|
|
44
|
+
} = await execa`git status --porcelain`;
|
|
45
45
|
if (stdout !== '') {
|
|
46
46
|
const onlyPnpmLockModifiedOnDrone = stdout.trim() === 'M pnpm-lock.yaml' && (await isDrone());
|
|
47
47
|
throw new Error(`Some changes have not been committed to Git:
|
|
@@ -63,7 +63,11 @@ var allChangesCommittedToGit$1 = {
|
|
|
63
63
|
const title$1 = 'ESLint';
|
|
64
64
|
async function eslintCheck() {
|
|
65
65
|
try {
|
|
66
|
-
await
|
|
66
|
+
await execa({
|
|
67
|
+
// Execute binaries in ./node_modules/.bin to avoid pnpm overhead
|
|
68
|
+
// https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries
|
|
69
|
+
preferLocal: true
|
|
70
|
+
})`eslint . --max-warnings 0 --format json`;
|
|
67
71
|
} catch (error) {
|
|
68
72
|
const {
|
|
69
73
|
stdout
|
|
@@ -76,7 +80,7 @@ async function eslintCheck() {
|
|
|
76
80
|
.filter(eslintResult => {
|
|
77
81
|
return eslintResult.errorCount > 0 || eslintResult.warningCount > 0;
|
|
78
82
|
});
|
|
79
|
-
} catch
|
|
83
|
+
} catch {
|
|
80
84
|
throw error;
|
|
81
85
|
}
|
|
82
86
|
if (eslintResults.length < 1 || !eslintResults.every(result => 'errorCount' in result && 'warningCount' in result)) {
|
|
@@ -115,12 +119,14 @@ const title$2 = 'ESLint config is latest version';
|
|
|
115
119
|
async function eslintConfigIsValid() {
|
|
116
120
|
const {
|
|
117
121
|
stdout: remoteVersion
|
|
118
|
-
} = await
|
|
122
|
+
} = await execa`npm show eslint-config-upleveled version`;
|
|
119
123
|
let localVersion;
|
|
120
124
|
try {
|
|
121
125
|
const eslintConfigPackageJsonPath = require$1.resolve('eslint-config-upleveled/package.json');
|
|
122
126
|
localVersion = JSON.parse(await promises.readFile(eslintConfigPackageJsonPath, 'utf-8')).version;
|
|
123
|
-
} catch
|
|
127
|
+
} catch {
|
|
128
|
+
// Swallow error
|
|
129
|
+
}
|
|
124
130
|
if (typeof localVersion === 'undefined') {
|
|
125
131
|
throw new Error(`The UpLeveled ESLint Config has not been installed - please install using the instructions on https://www.npmjs.com/package/eslint-config-upleveled
|
|
126
132
|
`);
|
|
@@ -132,7 +138,7 @@ async function eslintConfigIsValid() {
|
|
|
132
138
|
let eslintConfigMatches;
|
|
133
139
|
try {
|
|
134
140
|
eslintConfigMatches = (await promises.readFile('./eslint.config.js', 'utf-8')).trim() === "export { default } from 'eslint-config-upleveled';";
|
|
135
|
-
} catch
|
|
141
|
+
} catch {
|
|
136
142
|
throw new Error(`Error reading your eslint.config.js file - please delete the file if it exists and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled
|
|
137
143
|
`);
|
|
138
144
|
}
|
|
@@ -176,7 +182,7 @@ const title$3 = 'GitHub repo has deployed project link under About';
|
|
|
176
182
|
async function linkOnGithubAbout() {
|
|
177
183
|
const {
|
|
178
184
|
stdout
|
|
179
|
-
} = await
|
|
185
|
+
} = await execa`git remote get-url origin`;
|
|
180
186
|
const repoUrl = stdout.replace('git@github.com:', 'https://github.com/').replace('.git', '');
|
|
181
187
|
const html = await (await fetch(repoUrl)).text();
|
|
182
188
|
const $ = cheerio.load(html);
|
|
@@ -215,13 +221,13 @@ function normalizeNewlines(input) {
|
|
|
215
221
|
|
|
216
222
|
const title$4 = 'node_modules/ folder ignored in Git';
|
|
217
223
|
async function nodeModulesIgnoredFromGit() {
|
|
218
|
-
if ((await
|
|
224
|
+
if ((await execa`git ls-files node_modules/`).stdout !== '') {
|
|
219
225
|
throw new Error(`node_modules/ folder committed to Git. Remove it using:
|
|
220
226
|
|
|
221
227
|
${commandExample('git rm -r --cached node_modules')}
|
|
222
228
|
`);
|
|
223
229
|
}
|
|
224
|
-
if ((await
|
|
230
|
+
if ((await execa`git ls-files .gitignore`).stdout !== '.gitignore') {
|
|
225
231
|
throw new Error('.gitignore file not found');
|
|
226
232
|
}
|
|
227
233
|
const nodeModulesInGitignore = normalizeNewlines(await promises.readFile('./.gitignore', 'utf8')).split('\n').reduce((found, line) => found || /^\/?node_modules\/?$/.test(line), false);
|
|
@@ -239,17 +245,6 @@ var nodeModulesIgnoredFromGit$1 = {
|
|
|
239
245
|
const projectPackageJson = /*#__PURE__*/JSON.parse(await /*#__PURE__*/promises.readFile('package.json', 'utf-8'));
|
|
240
246
|
const preflightPackageJson = /*#__PURE__*/JSON.parse(await /*#__PURE__*/promises.readFile( /*#__PURE__*/new URL('../package.json', import.meta.url), 'utf-8'));
|
|
241
247
|
|
|
242
|
-
const title$5 = 'Next.js project has sharp installed';
|
|
243
|
-
function nextJsProjectHasSharpInstalled() {
|
|
244
|
-
const dependenciesPackageNames = Object.keys(projectPackageJson.dependencies || {});
|
|
245
|
-
if (dependenciesPackageNames.includes('next') && !dependenciesPackageNames.includes('sharp')) {
|
|
246
|
-
throw new Error(`Next.js projects should have sharp installed for better image optimization. Install it with:
|
|
247
|
-
|
|
248
|
-
${commandExample('pnpm add sharp')}
|
|
249
|
-
`);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
248
|
const client = /*#__PURE__*/algoliasearch(
|
|
254
249
|
// Application ID and API key specific to UpLeveled
|
|
255
250
|
// Preflight. Please don't use anywhere else without
|
|
@@ -258,7 +253,7 @@ const client = /*#__PURE__*/algoliasearch(
|
|
|
258
253
|
// Application ID
|
|
259
254
|
'ec73550aa8b2936dab436d4e02144784');
|
|
260
255
|
const index = /*#__PURE__*/client.initIndex('npm-search');
|
|
261
|
-
const title$
|
|
256
|
+
const title$5 = 'No dependencies without types';
|
|
262
257
|
// This is a naive check for matching @types/<pkg name> packages
|
|
263
258
|
// that the student hasn't yet installed. It is not intended to
|
|
264
259
|
// be an exhaustive check for any types for all packages.
|
|
@@ -277,11 +272,15 @@ async function noDependenciesWithoutTypes() {
|
|
|
277
272
|
if ('types' in modulePackageJson || 'typings' in modulePackageJson) {
|
|
278
273
|
return filteredDependencies;
|
|
279
274
|
}
|
|
280
|
-
} catch
|
|
275
|
+
} catch {
|
|
276
|
+
// Swallow error
|
|
277
|
+
}
|
|
281
278
|
let indexDTsPath;
|
|
282
279
|
try {
|
|
283
280
|
indexDTsPath = require.resolve(`${dependency}/index.d.ts`);
|
|
284
|
-
} catch
|
|
281
|
+
} catch {
|
|
282
|
+
// Swallow error
|
|
283
|
+
}
|
|
285
284
|
// If the index.d.ts file exists inside the module's directory, bail out
|
|
286
285
|
if (indexDTsPath && existsSync(indexDTsPath)) {
|
|
287
286
|
return filteredDependencies;
|
|
@@ -319,11 +318,11 @@ async function noDependenciesWithoutTypes() {
|
|
|
319
318
|
|
|
320
319
|
const {
|
|
321
320
|
stdout: preflightBinPath
|
|
322
|
-
} = await /*#__PURE__*/
|
|
321
|
+
} = await /*#__PURE__*/execa({
|
|
323
322
|
cwd: /*#__PURE__*/dirname( /*#__PURE__*/fileURLToPath(import.meta.url))
|
|
324
|
-
})
|
|
323
|
+
})`pnpm bin`;
|
|
325
324
|
|
|
326
|
-
const title$
|
|
325
|
+
const title$6 = 'No unused dependencies';
|
|
327
326
|
async function noUnusedAndMissingDependencies() {
|
|
328
327
|
const ignoredPackagePatterns = [
|
|
329
328
|
// Unused dependency detected in https://github.com/upleveled/next-portfolio-dev
|
|
@@ -358,7 +357,7 @@ async function noUnusedAndMissingDependencies() {
|
|
|
358
357
|
// Next.js
|
|
359
358
|
'sharp'].join(',');
|
|
360
359
|
try {
|
|
361
|
-
await
|
|
360
|
+
await execa`${preflightBinPath}/depcheck --ignores="${ignoredPackagePatterns}"`;
|
|
362
361
|
} catch (error) {
|
|
363
362
|
const {
|
|
364
363
|
stdout
|
|
@@ -390,11 +389,11 @@ async function noUnusedAndMissingDependencies() {
|
|
|
390
389
|
}
|
|
391
390
|
}
|
|
392
391
|
|
|
393
|
-
const title$
|
|
392
|
+
const title$7 = 'No extraneous files committed to Git';
|
|
394
393
|
async function noExtraneousFilesCommittedToGit() {
|
|
395
394
|
const {
|
|
396
395
|
stdout
|
|
397
|
-
} = await
|
|
396
|
+
} = await execa`git ls-files .DS_Store yarn-error.log npm-debug.log`;
|
|
398
397
|
if (stdout !== '') {
|
|
399
398
|
throw new Error(`Extraneous files committed to Git:
|
|
400
399
|
${stdout}
|
|
@@ -410,15 +409,15 @@ async function noExtraneousFilesCommittedToGit() {
|
|
|
410
409
|
|
|
411
410
|
var noExtraneousFilesCommittedToGit$1 = {
|
|
412
411
|
__proto__: null,
|
|
413
|
-
title: title$
|
|
412
|
+
title: title$7,
|
|
414
413
|
'default': noExtraneousFilesCommittedToGit
|
|
415
414
|
};
|
|
416
415
|
|
|
417
|
-
const title$
|
|
416
|
+
const title$8 = 'No secrets committed to Git';
|
|
418
417
|
async function noSecretsCommittedToGit() {
|
|
419
418
|
const {
|
|
420
419
|
stdout
|
|
421
|
-
} = await
|
|
420
|
+
} = await execa`git ls-files .env .env*.local`;
|
|
422
421
|
if (stdout !== '') {
|
|
423
422
|
throw new Error(`Secrets committed to Git 😱:
|
|
424
423
|
${stdout}
|
|
@@ -440,15 +439,15 @@ async function noSecretsCommittedToGit() {
|
|
|
440
439
|
|
|
441
440
|
var noSecretsCommittedToGit$1 = {
|
|
442
441
|
__proto__: null,
|
|
443
|
-
title: title$
|
|
442
|
+
title: title$8,
|
|
444
443
|
'default': noSecretsCommittedToGit
|
|
445
444
|
};
|
|
446
445
|
|
|
447
|
-
const title$
|
|
446
|
+
const title$9 = 'Preflight is latest version';
|
|
448
447
|
async function preflightIsLatestVersion() {
|
|
449
448
|
const {
|
|
450
449
|
stdout: remoteVersion
|
|
451
|
-
} = await
|
|
450
|
+
} = await execa`npm show @upleveled/preflight version`;
|
|
452
451
|
if (semver.gt(remoteVersion, preflightPackageJson.version)) {
|
|
453
452
|
throw new Error(`Your current version of Preflight (${preflightPackageJson.version}) is older than the latest version ${remoteVersion} - upgrade with:
|
|
454
453
|
|
|
@@ -459,14 +458,18 @@ async function preflightIsLatestVersion() {
|
|
|
459
458
|
|
|
460
459
|
var preflightIsLatestVersion$1 = {
|
|
461
460
|
__proto__: null,
|
|
462
|
-
title: title$
|
|
461
|
+
title: title$9,
|
|
463
462
|
'default': preflightIsLatestVersion
|
|
464
463
|
};
|
|
465
464
|
|
|
466
|
-
const title$
|
|
465
|
+
const title$a = 'Prettier';
|
|
467
466
|
async function prettierCheck() {
|
|
468
467
|
try {
|
|
469
|
-
await
|
|
468
|
+
await execa({
|
|
469
|
+
// Execute binaries in ./node_modules/.bin to avoid pnpm overhead
|
|
470
|
+
// https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries
|
|
471
|
+
preferLocal: true
|
|
472
|
+
})`prettier "**/*.{js,jsx,ts,tsx,css,scss,sql}" --list-different --end-of-line auto`;
|
|
470
473
|
} catch (error) {
|
|
471
474
|
const {
|
|
472
475
|
stdout,
|
|
@@ -488,11 +491,11 @@ async function prettierCheck() {
|
|
|
488
491
|
|
|
489
492
|
var prettier = {
|
|
490
493
|
__proto__: null,
|
|
491
|
-
title: title$
|
|
494
|
+
title: title$a,
|
|
492
495
|
'default': prettierCheck
|
|
493
496
|
};
|
|
494
497
|
|
|
495
|
-
const title$
|
|
498
|
+
const title$b = 'Project folder name matches correct format';
|
|
496
499
|
function projectFolderNameMatchesCorrectFormat() {
|
|
497
500
|
const currentDirectoryName = path.basename(process.cwd());
|
|
498
501
|
const lowercaseHyphenedDirectoryName = currentDirectoryName.toLowerCase().replaceAll(' ', '-');
|
|
@@ -510,15 +513,19 @@ function projectFolderNameMatchesCorrectFormat() {
|
|
|
510
513
|
|
|
511
514
|
var projectFolderNameMatchesCorrectFormat$1 = {
|
|
512
515
|
__proto__: null,
|
|
513
|
-
title: title$
|
|
516
|
+
title: title$b,
|
|
514
517
|
'default': projectFolderNameMatchesCorrectFormat
|
|
515
518
|
};
|
|
516
519
|
|
|
517
520
|
const supportedStylelintFileExtensions = ['css', 'sass', 'scss', 'less', 'js', 'tsx', 'jsx'];
|
|
518
|
-
const title$
|
|
521
|
+
const title$c = 'Stylelint';
|
|
519
522
|
async function stylelintCheck() {
|
|
520
523
|
try {
|
|
521
|
-
await
|
|
524
|
+
await execa({
|
|
525
|
+
// Execute binaries in ./node_modules/.bin to avoid pnpm overhead
|
|
526
|
+
// https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries
|
|
527
|
+
preferLocal: true
|
|
528
|
+
})`stylelint **/*.{${supportedStylelintFileExtensions.join(',')}} --max-warnings 0 --formatter json`;
|
|
522
529
|
} catch (error) {
|
|
523
530
|
const {
|
|
524
531
|
stdout
|
|
@@ -526,7 +533,7 @@ async function stylelintCheck() {
|
|
|
526
533
|
let stylelintResults;
|
|
527
534
|
try {
|
|
528
535
|
stylelintResults = JSON.parse(stdout).filter(stylelintResult => stylelintResult.errored === true);
|
|
529
|
-
} catch
|
|
536
|
+
} catch {
|
|
530
537
|
throw error;
|
|
531
538
|
}
|
|
532
539
|
if (stylelintResults.length < 1 || !stylelintResults.every(result => 'errored' in result)) {
|
|
@@ -557,21 +564,23 @@ async function stylelintCheck() {
|
|
|
557
564
|
var stylelint = {
|
|
558
565
|
__proto__: null,
|
|
559
566
|
supportedStylelintFileExtensions: supportedStylelintFileExtensions,
|
|
560
|
-
title: title$
|
|
567
|
+
title: title$c,
|
|
561
568
|
'default': stylelintCheck
|
|
562
569
|
};
|
|
563
570
|
|
|
564
571
|
const require$2 = /*#__PURE__*/createRequire(`${/*#__PURE__*/process.cwd()}/`);
|
|
565
|
-
const title$
|
|
572
|
+
const title$d = 'Stylelint config is latest version';
|
|
566
573
|
async function stylelintConfigIsValid() {
|
|
567
574
|
const {
|
|
568
575
|
stdout: remoteVersion
|
|
569
|
-
} = await
|
|
576
|
+
} = await execa`npm show stylelint-config-upleveled version`;
|
|
570
577
|
let localVersion;
|
|
571
578
|
try {
|
|
572
579
|
const stylelintConfigPackageJsonPath = require$2.resolve('stylelint-config-upleveled/package.json');
|
|
573
580
|
localVersion = JSON.parse(await promises.readFile(stylelintConfigPackageJsonPath, 'utf-8')).version;
|
|
574
|
-
} catch
|
|
581
|
+
} catch {
|
|
582
|
+
// Swallow error
|
|
583
|
+
}
|
|
575
584
|
if (typeof localVersion === 'undefined') {
|
|
576
585
|
throw new Error(`The UpLeveled Stylelint Config has not been installed - please install using the instructions on https://www.npmjs.com/package/eslint-config-upleveled
|
|
577
586
|
`);
|
|
@@ -589,7 +598,7 @@ const config = {
|
|
|
589
598
|
};
|
|
590
599
|
|
|
591
600
|
export default config;`;
|
|
592
|
-
} catch
|
|
601
|
+
} catch {
|
|
593
602
|
throw new Error(`Error reading your stylelint.config.js file - please delete the file if it exists and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled
|
|
594
603
|
`);
|
|
595
604
|
}
|
|
@@ -620,15 +629,15 @@ export default config;`;
|
|
|
620
629
|
|
|
621
630
|
var stylelintConfigIsValid$1 = {
|
|
622
631
|
__proto__: null,
|
|
623
|
-
title: title$
|
|
632
|
+
title: title$d,
|
|
624
633
|
'default': stylelintConfigIsValid
|
|
625
634
|
};
|
|
626
635
|
|
|
627
|
-
const title$
|
|
636
|
+
const title$e = 'Use single package manager';
|
|
628
637
|
async function useSinglePackageManager() {
|
|
629
638
|
const {
|
|
630
639
|
stdout
|
|
631
|
-
} = await
|
|
640
|
+
} = await execa`git ls-files package-lock.json yarn.lock`;
|
|
632
641
|
if (stdout !== '') {
|
|
633
642
|
throw new Error(`package-lock.json or yarn.lock file committed to Git. Remove it with:
|
|
634
643
|
|
|
@@ -647,7 +656,7 @@ async function useSinglePackageManager() {
|
|
|
647
656
|
|
|
648
657
|
var useSinglePackageManager$1 = {
|
|
649
658
|
__proto__: null,
|
|
650
|
-
title: title$
|
|
659
|
+
title: title$e,
|
|
651
660
|
'default': useSinglePackageManager
|
|
652
661
|
};
|
|
653
662
|
|
|
@@ -665,14 +674,11 @@ projectFolderNameMatchesCorrectFormat$1,
|
|
|
665
674
|
// Dependencies
|
|
666
675
|
{
|
|
667
676
|
title: 'No dependency problems',
|
|
668
|
-
task: (ctx, task) => task.newListr([
|
|
669
|
-
title: title$
|
|
670
|
-
task: nextJsProjectHasSharpInstalled
|
|
671
|
-
}]), {
|
|
672
|
-
title: title$7,
|
|
677
|
+
task: (ctx, task) => task.newListr([{
|
|
678
|
+
title: title$6,
|
|
673
679
|
task: noUnusedAndMissingDependencies
|
|
674
680
|
}, {
|
|
675
|
-
title: title$
|
|
681
|
+
title: title$5,
|
|
676
682
|
task: noDependenciesWithoutTypes
|
|
677
683
|
}])
|
|
678
684
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.esm.js","sources":["../src/util/commandExample.ts","../src/util/drone.ts","../src/checks/allChangesCommittedToGit.ts","../src/checks/eslint.ts","../src/checks/eslintConfigIsValid.ts","../src/util/randomUserAgent.ts","../src/checks/linkOnGithubAbout.ts","../src/util/crossPlatform.ts","../src/checks/nodeModulesIgnoredFromGit.ts","../src/util/packageJson.ts","../src/checks/noDependencyProblems/nextJsProjectHasSharpInstalled.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/stylelint.ts","../src/checks/stylelintConfigIsValid.ts","../src/checks/useSinglePackageManager.ts","../src/index.ts"],"sourcesContent":["import chalk from 'chalk';\n\n// https://www.compart.com/en/unicode/U+2800\n// eslint-disable-next-line security/detect-bidi-characters -- Intentional use of unusual character for formatting\nconst emptyBrailleCharacter = '';\n\nexport 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/drone';\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 onlyPnpmLockModifiedOnDrone =\n stdout.trim() === 'M pnpm-lock.yaml' && (await isDrone());\n throw new Error(\n `Some changes have not been committed to Git:\n ${stdout}${\n onlyPnpmLockModifiedOnDrone\n ? `\n\n The only file with changes is the pnpm-lock.yaml file, indicating that npm was incorrectly used in addition to pnpm (eg. an \"npm install\" command was run). To fix this, force regeneration of the pnpm-lock.yaml file locally with the following command and then commit the changes:\n\n ${commandExample('pnpm install --force')}`\n : ''\n }\n `,\n );\n }\n}\n","import { sep } from 'node:path';\nimport { ESLint } from 'eslint';\nimport { execaCommand } from 'execa';\n\nexport const title = 'ESLint';\n\nexport default async function eslintCheck() {\n try {\n await execaCommand('pnpm eslint . --max-warnings 0 --format json');\n } catch (error) {\n const { stdout } = error as { stdout: string };\n\n let eslintResults;\n\n try {\n eslintResults = (JSON.parse(stdout) as ESLint.LintResult[])\n // Filter out results with no problems, which the ESLint CLI\n // still reports with the `--format json` flag\n .filter((eslintResult) => {\n return eslintResult.errorCount > 0 || eslintResult.warningCount > 0;\n });\n } catch (parseError) {\n throw error;\n }\n\n if (\n eslintResults.length < 1 ||\n !eslintResults.every(\n (result) => 'errorCount' in result && 'warningCount' in result,\n )\n ) {\n throw new Error(\n `Unexpected shape of ESLint JSON related to .errorCount and .warningCount properties - please report this to the UpLeveled engineering team, including the following output:\n ${stdout}\n `,\n );\n }\n\n throw new Error(\n `ESLint problems found in the following files:\n ${eslintResults\n // Make paths relative to the project:\n //\n // Before:\n // macOS / Linux: /home/projects/next-student-project/app/api/hello/route.js\n // Windows: C:\\Users\\Lukas\\projects\\next-student-project\\app\\api\\hello\\route.js\n //\n // After:\n // macOS / Linux: app/api/hello/route.js\n // Windows: app\\api\\hello\\route.js\n .map(({ filePath }) => filePath.replace(`${process.cwd()}${sep}`, ''))\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';\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 eslint-config-upleveled version',\n );\n\n let localVersion: string | undefined;\n\n try {\n const eslintConfigPackageJsonPath = require.resolve(\n 'eslint-config-upleveled/package.json',\n );\n\n localVersion = JSON.parse(\n await fs.readFile(eslintConfigPackageJsonPath, 'utf-8'),\n ).version;\n } catch (error) {}\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/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 older than the latest version ${remoteVersion} - upgrade by running all lines of the install instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n let eslintConfigMatches;\n\n try {\n eslintConfigMatches =\n (await fs.readFile('./eslint.config.js', 'utf-8')).trim() ===\n \"export { default } from 'eslint-config-upleveled';\";\n } catch (error) {\n throw new Error(\n `Error reading your eslint.config.js file - please delete the file if it exists and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n if (!eslintConfigMatches) {\n throw new Error(\n `Your eslint.config.js file does not match the configuration file template - please delete the file and reinstall the config using the instructions on https://www.npmjs.com/package/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 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 / Fly.io 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","const CRLF = '\\r\\n';\n\nexport function normalizeNewlines(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 { promises as fs } from 'node:fs';\nimport { execaCommand } from 'execa';\nimport { commandExample } from '../util/commandExample';\nimport { normalizeNewlines } from '../util/crossPlatform';\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 = normalizeNewlines(\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 { promises as fs } from 'node:fs';\nimport { URL } from 'node:url';\n\ntype PackageJson = {\n name: string;\n version: string;\n description?: string;\n keywords?: string;\n homepage?: string;\n bugs?: {\n email?: string;\n url?: string;\n };\n license?: string;\n author?:\n | string\n | {\n name: string;\n email?: string;\n url?: string;\n };\n contributors?:\n | string[]\n | {\n name: string;\n email?: string;\n url?: string;\n }[];\n files?: string[];\n main?: string;\n browser?: string;\n bin?: Record<string, string>;\n man?: string;\n directories?: {\n lib?: string;\n bin?: string;\n man?: string;\n doc?: string;\n example?: string;\n test?: string;\n };\n repository?: {\n type?: 'git';\n url?: string;\n directory?: string;\n };\n scripts?: Record<string, string>;\n config?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n bundledDependencies?: string[];\n engines?: Record<string, string>;\n os?: string[];\n cpu?: string[];\n};\n\nexport const projectPackageJson = JSON.parse(\n await fs.readFile('package.json', 'utf-8'),\n) as PackageJson;\n\nexport const preflightPackageJson = JSON.parse(\n await fs.readFile(new URL('../package.json', import.meta.url), 'utf-8'),\n) as PackageJson;\n","import { commandExample } from '../../util/commandExample';\nimport { projectPackageJson } from '../../util/packageJson';\n\nexport const title = 'Next.js project has sharp installed';\n\nexport default function nextJsProjectHasSharpInstalled() {\n const dependenciesPackageNames = Object.keys(\n projectPackageJson.dependencies || {},\n );\n if (\n dependenciesPackageNames.includes('next') &&\n !dependenciesPackageNames.includes('sharp')\n ) {\n throw new Error(\n `Next.js projects should have sharp installed for better image optimization. Install it with:\n\n ${commandExample('pnpm add sharp')}\n `,\n );\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';\nimport { projectPackageJson } from '../../util/packageJson';\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 dependenciesWithMissingTypes = await pReduce(\n Object.keys(projectPackageJson.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 (error) {}\n\n let indexDTsPath;\n\n try {\n indexDTsPath = require.resolve(`${dependency}/index.d.ts`);\n } catch (error) {}\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 let results: AlgoliaObj;\n\n try {\n results = await index.getObject<AlgoliaObj>(dependency, {\n attributesToRetrieve: ['types'],\n });\n } catch (error) {\n // Show dependency name if Algolia's `index.getObject()` throws with an\n // error message (such as the error message \"ObjectID does not exist\"\n // when a package cannot be found in the index)\n throw new Error(\n `Algolia error for \\`${dependency}\\`: ${(error as Error).message}`,\n );\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 (\n Object.keys(projectPackageJson.devDependencies || {}).includes(\n definitelyTypedPackageName,\n )\n ) {\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 `pnpm add --save-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 --save-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\nexport const { stdout: preflightBinPath } = await execaCommand(`pnpm bin`, {\n cwd: dirname(fileURLToPath(import.meta.url)),\n});\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 // Tailwind CSS\n '@tailwindcss/jit',\n 'autoprefixer',\n 'postcss',\n 'tailwindcss',\n\n // Sass (eg. in Next.js)\n 'sass',\n\n // Prettier and plugins\n 'prettier',\n 'prettier-plugin-*',\n\n // ESLint configuration\n '@ts-safeql/eslint-plugin',\n 'libpg-query',\n\n // TODO: Remove this once depcheck issue is fixed:\n // PR: https://github.com/depcheck/depcheck/pull/790\n // Issue: https://github.com/depcheck/depcheck/issues/791\n //\n // Stylelint configuration\n 'stylelint',\n 'stylelint-config-upleveled',\n\n // Testing\n '@testing-library/user-event',\n 'jest',\n 'jest-environment-jsdom',\n 'playwright',\n\n // `expect` required for proper types with `@testing-library/jest-dom` with `@jest/globals` and pnpm\n // https://github.com/testing-library/jest-dom/issues/123#issuecomment-1536828385\n // TODO: Remove when we switch from Jest to Vitest\n 'expect',\n\n // `ts-node` required for jest.config.ts\n // https://jestjs.io/docs/29.6/configuration#:~:text=To%20read%20TypeScript%20configuration%20files%20Jest%20requires%20ts%2Dnode.%20Make%20sure%20it%20is%20installed%20in%20your%20project\n // TODO: Remove when usage of tsx is allowed\n // https://github.com/jestjs/jest/issues/11989\n 'ts-node',\n\n // TypeScript\n 'typescript',\n '@types/*',\n 'tsx',\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('pnpm 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('pnpm add <dependency name here>')}\n `);\n }\n\n if (messages.length > 0) 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 os from 'node:os';\nimport { execaCommand } from 'execa';\nimport semver from 'semver';\nimport { commandExample } from '../util/commandExample';\nimport { preflightPackageJson } from '../util/packageJson';\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 if (semver.gt(remoteVersion, preflightPackageJson.version)) {\n throw new Error(\n `Your current version of Preflight (${\n preflightPackageJson.version\n }) is older than the latest version ${remoteVersion} - upgrade with:\n\n ${commandExample(\n `${\n os.platform() === 'linux' ? 'sudo ' : ''\n }pnpm add --global @upleveled/preflight`,\n )}\n `,\n );\n }\n}\n","import { execaCommand } from 'execa';\nimport { normalizeNewlines } from '../util/crossPlatform';\n\nexport const title = 'Prettier';\n\nexport default async function prettierCheck() {\n try {\n await execaCommand(\n 'pnpm prettier \"**/*.{js,jsx,ts,tsx,css,scss,sql}\" --list-different --end-of-line auto',\n );\n } catch (error) {\n const { stdout, stderr } = error as { stdout: string; stderr: string };\n\n if (!stdout || stderr) {\n throw error;\n }\n\n const unformattedFiles = normalizeNewlines(stdout).split('\\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 For each of the files above, open the file in your editor and save the file. This will format the file with Prettier, which will cause changes to appear in Git.\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 { sep } from 'node:path';\nimport { execaCommand } from 'execa';\nimport { LintResult } from 'stylelint';\n\nexport const supportedStylelintFileExtensions = [\n 'css',\n 'sass',\n 'scss',\n 'less',\n 'js',\n 'tsx',\n 'jsx',\n];\n\nexport const title = 'Stylelint';\n\nexport default async function stylelintCheck() {\n try {\n await execaCommand(\n `pnpm stylelint **/*.{${supportedStylelintFileExtensions.join(\n ',',\n )}} --max-warnings 0 --formatter json`,\n );\n } catch (error) {\n const { stdout } = error as { stdout: string };\n\n let stylelintResults;\n\n try {\n stylelintResults = (JSON.parse(stdout) as LintResult[]).filter(\n (stylelintResult) => stylelintResult.errored === true,\n );\n } catch (parseError) {\n throw error;\n }\n\n if (\n stylelintResults.length < 1 ||\n !stylelintResults.every((result) => 'errored' in result)\n ) {\n throw new Error(\n `Unexpected shape of Stylelint JSON related to .errored properties - please report this to the UpLeveled engineering team, including the following output:\n ${stdout}\n `,\n );\n }\n\n throw new Error(\n `Stylelint problems found in the following files:\n ${stylelintResults\n // Make paths relative to the project:\n //\n // Before:\n // macOS / Linux: /home/projects/random-color-generator-react-app/src/index.css\n // Windows: C:\\Users\\Lukas\\projects\\random-color-generator-react-app\\src\\index.css\n //\n // After:\n // macOS / Linux: src/index.css\n // Windows: src\\index.css\n .map(({ source }) => source!.replace(`${process.cwd()}${sep}`, ''))\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 { supportedStylelintFileExtensions } from './stylelint';\n\nconst require = createRequire(`${process.cwd()}/`);\n\nexport const title = 'Stylelint config is latest version';\n\nexport default async function stylelintConfigIsValid() {\n const { stdout: remoteVersion } = await execaCommand(\n 'npm show stylelint-config-upleveled version',\n );\n\n let localVersion: string | undefined;\n\n try {\n const stylelintConfigPackageJsonPath = require.resolve(\n 'stylelint-config-upleveled/package.json',\n );\n\n localVersion = JSON.parse(\n await fs.readFile(stylelintConfigPackageJsonPath, 'utf-8'),\n ).version;\n } catch (error) {}\n\n if (typeof localVersion === 'undefined') {\n throw new Error(\n `The UpLeveled Stylelint Config has not been installed - please install using the instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n if (semver.gt(remoteVersion, localVersion)) {\n throw new Error(\n `Your current version of the UpLeveled Stylelint Config (${localVersion}) is older than the latest version ${remoteVersion} - upgrade by running:\n\n pnpm add stylelint-config-upleveled@${remoteVersion}`,\n );\n }\n\n let stylelintConfigMatches;\n\n try {\n stylelintConfigMatches =\n (await fs.readFile('./stylelint.config.js', 'utf-8')).trim() ===\n `/** @type {import('stylelint').Config} */\nconst config = {\n extends: ['stylelint-config-upleveled'],\n};\n\nexport default config;`;\n } catch (error) {\n throw new Error(\n `Error reading your stylelint.config.js file - please delete the file if it exists and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n if (!stylelintConfigMatches) {\n throw new Error(\n `Your stylelint.config.js file does not match the configuration file template - please delete the file and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n const stylelintDisableOccurrences = [];\n\n for await (const { path } of readdirp('.', {\n directoryFilter: ['!.git', '!.next', '!node_modules'],\n fileFilter: supportedStylelintFileExtensions.map(\n (fileExtension) => `*.${fileExtension}`,\n ),\n })) {\n const fileContents = await fs.readFile(path, 'utf-8');\n if (fileContents.includes('stylelint-disable')) {\n stylelintDisableOccurrences.push(path);\n }\n }\n\n if (stylelintDisableOccurrences.length > 0) {\n throw new Error(\n `Stylelint has been disabled in the following files:\n ${stylelintDisableOccurrences.join('\\n')}\n\n Remove all comments disabling or modifying Stylelint rule configuration (eg. stylelint-disable and stylelint-disable-next-line comments) and fix the problems\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(\n 'git ls-files package-lock.json yarn.lock',\n );\n\n if (stdout !== '') {\n throw new Error(\n `package-lock.json or yarn.lock 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 another package manager was used in addition to pnpm (eg. \"npm install\" or \"yarn add\" was run). In order to avoid issues with the state of the pnpm-lock.yaml file, we suggest also forcing regeneration this file with the following command:\n\n ${commandExample('pnpm install --force')}\n `,\n );\n }\n}\n","import { Listr, ListrTask } 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 nextJsProjectHasSharpInstalled from './checks/noDependencyProblems/nextJsProjectHasSharpInstalled.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 stylelint from './checks/stylelint.js';\nimport * as stylelintConfigIsValid from './checks/stylelintConfigIsValid.js';\nimport * as useSinglePackageManager from './checks/useSinglePackageManager.js';\nimport { CtxParam } from './types/CtxParam.js';\nimport { TaskParam } from './types/TaskParam.js';\nimport {\n preflightPackageJson,\n projectPackageJson,\n} from './util/packageJson.js';\n\nconst projectDependencies = projectPackageJson.dependencies || {};\n\nconsole.log(`🚀 UpLeveled Preflight v${preflightPackageJson.version}`);\n\nconst listrTasks: ListrTask[] = [\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 ...(!Object.keys(projectDependencies).includes('next')\n ? []\n : [\n {\n title: nextJsProjectHasSharpInstalled.title,\n task: nextJsProjectHasSharpInstalled.default,\n },\n ]),\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 ...(!(\n '@upleveled/react-scripts' in projectDependencies ||\n 'next' in projectDependencies\n )\n ? []\n : [stylelint]),\n prettier,\n\n // Version and configuration checks\n eslintConfigIsValid,\n ...(!(\n '@upleveled/react-scripts' in projectDependencies ||\n 'next' in projectDependencies\n )\n ? []\n : [stylelintConfigIsValid]),\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\nconst tasks = new Listr(listrTasks, {\n exitOnError: false,\n collectErrors: 'minimal',\n rendererOptions: {\n collapseErrors: false,\n removeEmptyLines: false,\n formatOutput: 'wrap',\n },\n fallbackRenderer: 'verbose',\n concurrent: 5,\n});\n\nawait tasks.run();\n\nif (tasks.errors.length > 0) {\n process.exit(1);\n}\n"],"names":["emptyBrailleCharacter","commandExample","command","chalk","dim","isDrone","stdout","execaCommand","reject","test","title","allChangesCommittedToGit","replSlug","isRunningInReplIt","fs","writeFile","onlyPnpmLockModifiedOnDrone","trim","Error","eslintCheck","error","eslintResults","JSON","parse","filter","eslintResult","errorCount","warningCount","parseError","length","every","result","map","filePath","replace","process","cwd","sep","join","require","createRequire","eslintConfigIsValid","remoteVersion","localVersion","eslintConfigPackageJsonPath","resolve","readFile","version","semver","gt","eslintConfigMatches","eslintDisableOccurrences","path","readdirp","directoryFilter","fileFilter","fileContents","push","randomUserAgent","randomIndex","Math","floor","random","userAgents","linkOnGithubAbout","repoUrl","html","fetch","text","$","cheerio","load","urlInAboutSection","nextAll","children","next","attr","response","headers","ok","status","statusText","CRLF","normalizeNewlines","input","TypeError","RegExp","nodeModulesIgnoredFromGit","nodeModulesInGitignore","split","reduce","found","line","projectPackageJson","preflightPackageJson","URL","import","meta","url","nextJsProjectHasSharpInstalled","dependenciesPackageNames","Object","keys","dependencies","includes","client","algoliasearch","index","initIndex","noDependenciesWithoutTypes","dependenciesWithMissingTypes","pReduce","filteredDependencies","dependency","packageJsonPath","modulePackageJson","indexDTsPath","existsSync","results","getObject","attributesToRetrieve","message","definitelyTypedPackageName","_results$types","types","definitelyTyped","devDependencies","preflightBinPath","dirname","fileURLToPath","noUnusedAndMissingDependencies","ignoredPackagePatterns","startsWith","unusedDependenciesStdout","missingDependenciesStdout","messages","str","noExtraneousFilesCommittedToGit","noSecretsCommittedToGit","preflightIsLatestVersion","os","platform","prettierCheck","stderr","unformattedFiles","projectFolderNameMatchesCorrectFormat","currentDirectoryName","basename","lowercaseHyphenedDirectoryName","toLowerCase","replaceAll","supportedStylelintFileExtensions","stylelintCheck","stylelintResults","stylelintResult","errored","source","stylelintConfigIsValid","stylelintConfigPackageJsonPath","stylelintConfigMatches","stylelintDisableOccurrences","fileExtension","useSinglePackageManager","projectDependencies","console","log","listrTasks","task","ctx","newListr","eslint","stylelint","prettier","module","default","tasks","Listr","exitOnError","collectErrors","rendererOptions","collapseErrors","removeEmptyLines","formatOutput","fallbackRenderer","concurrent","run","errors","exit"],"mappings":";;;;;;;;;;;;;;;;AAEA;AACA;AACA,MAAMA,qBAAqB,GAAG,GAAG;SAEjBC,cAAcA,CAACC,OAAe;EAC5C,UAAUF,0BAA0BG,KAAK,CAACC,GAAG,CAAC,GAAG,KAAKF,SAAS;AACjE;;ACNO,eAAeG,OAAOA;EAC3B,MAAM;IAAEC;GAAQ,GAAG,MAAMC,YAAY,CAAC,qBAAqB,EAAE;IAC3DC,MAAM,EAAE;GACT,CAAC;EACF,OAAO,cAAc,CAACC,IAAI,CAACH,MAAM,CAAC;AACpC;;ACFO,MAAMI,KAAK,GAAG,8BAA8B;AAEnD,AAAe,eAAeC,wBAAwBA;EACpD,MAAM;IAAEL,MAAM,EAAEM;GAAU,GAAG,MAAML,YAAY,CAAC,iBAAiB,CAAC;EAElE,MAAM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,OAAO,CAACwJ,IAAI,CAAC,CAAC,CAAC;AACjB"}
|
|
1
|
+
{"version":3,"file":"preflight.esm.js","sources":["../src/util/commandExample.ts","../src/util/drone.ts","../src/checks/allChangesCommittedToGit.ts","../src/checks/eslint.ts","../src/checks/eslintConfigIsValid.ts","../src/util/randomUserAgent.ts","../src/checks/linkOnGithubAbout.ts","../src/util/crossPlatform.ts","../src/checks/nodeModulesIgnoredFromGit.ts","../src/util/packageJson.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/stylelint.ts","../src/checks/stylelintConfigIsValid.ts","../src/checks/useSinglePackageManager.ts","../src/index.ts"],"sourcesContent":["import chalk from 'chalk';\n\n// https://www.compart.com/en/unicode/U+2800\n// eslint-disable-next-line security/detect-bidi-characters -- Intentional use of unusual character for formatting\nconst emptyBrailleCharacter = '';\n\nexport 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({\n reject: false,\n })`cat /etc/os-release`;\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/drone';\n\nexport const title = 'All changes committed to Git';\n\nexport default async function allChangesCommittedToGit() {\n const { stdout: replSlug } = await execa`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`git status --porcelain`;\n\n if (stdout !== '') {\n const onlyPnpmLockModifiedOnDrone =\n stdout.trim() === 'M pnpm-lock.yaml' && (await isDrone());\n throw new Error(\n `Some changes have not been committed to Git:\n ${stdout}${\n onlyPnpmLockModifiedOnDrone\n ? `\n\n The only file with changes is the pnpm-lock.yaml file, indicating that npm was incorrectly used in addition to pnpm (eg. an \"npm install\" command was run). To fix this, force regeneration of the pnpm-lock.yaml file locally with the following command and then commit the changes:\n\n ${commandExample('pnpm install --force')}`\n : ''\n }\n `,\n );\n }\n}\n","import { sep } from 'node:path';\nimport { ESLint } from 'eslint';\nimport { execa } from 'execa';\n\nexport const title = 'ESLint';\n\nexport default async function eslintCheck() {\n try {\n await execa({\n // Execute binaries in ./node_modules/.bin to avoid pnpm overhead\n // https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries\n preferLocal: true,\n })`eslint . --max-warnings 0 --format json`;\n } catch (error) {\n const { stdout } = error as { stdout: string };\n\n let eslintResults;\n\n try {\n eslintResults = (JSON.parse(stdout) as ESLint.LintResult[])\n // Filter out results with no problems, which the ESLint CLI\n // still reports with the `--format json` flag\n .filter((eslintResult) => {\n return eslintResult.errorCount > 0 || eslintResult.warningCount > 0;\n });\n } catch {\n throw error;\n }\n\n if (\n eslintResults.length < 1 ||\n !eslintResults.every(\n (result) => 'errorCount' in result && 'warningCount' in result,\n )\n ) {\n throw new Error(\n `Unexpected shape of ESLint JSON related to .errorCount and .warningCount properties - please report this to the UpLeveled engineering team, including the following output:\n ${stdout}\n `,\n );\n }\n\n throw new Error(\n `ESLint problems found in the following files:\n ${eslintResults\n // Make paths relative to the project:\n //\n // Before:\n // macOS / Linux: /home/projects/next-student-project/app/api/hello/route.js\n // Windows: C:\\Users\\Lukas\\projects\\next-student-project\\app\\api\\hello\\route.js\n //\n // After:\n // macOS / Linux: app/api/hello/route.js\n // Windows: app\\api\\hello\\route.js\n .map(({ filePath }) => filePath.replace(`${process.cwd()}${sep}`, ''))\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';\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 } =\n await execa`npm show eslint-config-upleveled version`;\n\n let localVersion: string | undefined;\n\n try {\n const eslintConfigPackageJsonPath = require.resolve(\n 'eslint-config-upleveled/package.json',\n );\n\n localVersion = JSON.parse(\n await fs.readFile(eslintConfigPackageJsonPath, 'utf-8'),\n ).version;\n } catch {\n // Swallow error\n }\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/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 older than the latest version ${remoteVersion} - upgrade by running all lines of the install instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n let eslintConfigMatches;\n\n try {\n eslintConfigMatches =\n (await fs.readFile('./eslint.config.js', 'utf-8')).trim() ===\n \"export { default } from 'eslint-config-upleveled';\";\n } catch {\n throw new Error(\n `Error reading your eslint.config.js file - please delete the file if it exists and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n if (!eslintConfigMatches) {\n throw new Error(\n `Your eslint.config.js file does not match the configuration file template - please delete the file and reinstall the config using the instructions on https://www.npmjs.com/package/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 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`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 / Fly.io 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","const CRLF = '\\r\\n';\n\nexport function normalizeNewlines(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 { promises as fs } from 'node:fs';\nimport { execa } from 'execa';\nimport { commandExample } from '../util/commandExample';\nimport { normalizeNewlines } from '../util/crossPlatform';\n\nexport const title = 'node_modules/ folder ignored in Git';\n\nexport default async function nodeModulesIgnoredFromGit() {\n if ((await execa`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 execa`git ls-files .gitignore`).stdout !== '.gitignore') {\n throw new Error('.gitignore file not found');\n }\n\n const nodeModulesInGitignore = normalizeNewlines(\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 { promises as fs } from 'node:fs';\nimport { URL } from 'node:url';\n\ntype PackageJson = {\n name: string;\n version: string;\n description?: string;\n keywords?: string;\n homepage?: string;\n bugs?: {\n email?: string;\n url?: string;\n };\n license?: string;\n author?:\n | string\n | {\n name: string;\n email?: string;\n url?: string;\n };\n contributors?:\n | string[]\n | {\n name: string;\n email?: string;\n url?: string;\n }[];\n files?: string[];\n main?: string;\n browser?: string;\n bin?: Record<string, string>;\n man?: string;\n directories?: {\n lib?: string;\n bin?: string;\n man?: string;\n doc?: string;\n example?: string;\n test?: string;\n };\n repository?: {\n type?: 'git';\n url?: string;\n directory?: string;\n };\n scripts?: Record<string, string>;\n config?: Record<string, string>;\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n peerDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n bundledDependencies?: string[];\n engines?: Record<string, string>;\n os?: string[];\n cpu?: string[];\n};\n\nexport const projectPackageJson = JSON.parse(\n await fs.readFile('package.json', 'utf-8'),\n) as PackageJson;\n\nexport const preflightPackageJson = JSON.parse(\n await fs.readFile(new URL('../package.json', import.meta.url), 'utf-8'),\n) as PackageJson;\n","import { existsSync, promises as fs } from 'node:fs';\nimport algoliasearch from 'algoliasearch';\nimport pReduce from 'p-reduce';\nimport { commandExample } from '../../util/commandExample';\nimport { projectPackageJson } from '../../util/packageJson';\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 dependenciesWithMissingTypes = await pReduce(\n Object.keys(projectPackageJson.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 {\n // Swallow error\n }\n\n let indexDTsPath;\n\n try {\n indexDTsPath = require.resolve(`${dependency}/index.d.ts`);\n } catch {\n // Swallow error\n }\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 let results: AlgoliaObj;\n\n try {\n results = await index.getObject<AlgoliaObj>(dependency, {\n attributesToRetrieve: ['types'],\n });\n } catch (error) {\n // Show dependency name if Algolia's `index.getObject()` throws with an\n // error message (such as the error message \"ObjectID does not exist\"\n // when a package cannot be found in the index)\n throw new Error(\n `Algolia error for \\`${dependency}\\`: ${(error as Error).message}`,\n );\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 (\n Object.keys(projectPackageJson.devDependencies || {}).includes(\n definitelyTypedPackageName,\n )\n ) {\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 `pnpm add --save-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 --save-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 { execa } from 'execa';\n\nexport const { stdout: preflightBinPath } = await execa({\n cwd: dirname(fileURLToPath(import.meta.url)),\n})`pnpm bin`;\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 https://github.com/upleveled/next-portfolio-dev\n '@graphql-codegen/cli',\n\n // Tailwind CSS\n '@tailwindcss/jit',\n 'autoprefixer',\n 'postcss',\n 'tailwindcss',\n\n // Sass (eg. in Next.js)\n 'sass',\n\n // Prettier and plugins\n 'prettier',\n 'prettier-plugin-*',\n\n // ESLint configuration\n '@ts-safeql/eslint-plugin',\n 'libpg-query',\n\n // TODO: Remove this once depcheck issue is fixed:\n // PR: https://github.com/depcheck/depcheck/pull/790\n // Issue: https://github.com/depcheck/depcheck/issues/791\n //\n // Stylelint configuration\n 'stylelint',\n 'stylelint-config-upleveled',\n\n // Testing\n '@testing-library/user-event',\n 'jest',\n 'jest-environment-jsdom',\n 'playwright',\n\n // `expect` required for proper types with `@testing-library/jest-dom` with `@jest/globals` and pnpm\n // https://github.com/testing-library/jest-dom/issues/123#issuecomment-1536828385\n // TODO: Remove when we switch from Jest to Vitest\n 'expect',\n\n // `ts-node` required for jest.config.ts\n // https://jestjs.io/docs/29.6/configuration#:~:text=To%20read%20TypeScript%20configuration%20files%20Jest%20requires%20ts%2Dnode.%20Make%20sure%20it%20is%20installed%20in%20your%20project\n // TODO: Remove when usage of tsx is allowed\n // https://github.com/jestjs/jest/issues/11989\n 'ts-node',\n\n // TypeScript\n 'typescript',\n '@types/*',\n 'tsx',\n\n // Next.js\n 'sharp',\n ].join(',');\n\n try {\n await execa`${preflightBinPath}/depcheck --ignores=\"${ignoredPackagePatterns}\"`;\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('pnpm 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('pnpm add <dependency name here>')}\n `);\n }\n\n if (messages.length > 0) 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 } =\n await execa`git ls-files .DS_Store yarn-error.log npm-debug.log`;\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`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 os from 'node:os';\nimport { execa } from 'execa';\nimport semver from 'semver';\nimport { commandExample } from '../util/commandExample';\nimport { preflightPackageJson } from '../util/packageJson';\n\nexport const title = 'Preflight is latest version';\n\nexport default async function preflightIsLatestVersion() {\n const { stdout: remoteVersion } =\n await execa`npm show @upleveled/preflight version`;\n\n if (semver.gt(remoteVersion, preflightPackageJson.version)) {\n throw new Error(\n `Your current version of Preflight (${\n preflightPackageJson.version\n }) is older than the latest version ${remoteVersion} - upgrade with:\n\n ${commandExample(\n `${\n os.platform() === 'linux' ? 'sudo ' : ''\n }pnpm add --global @upleveled/preflight`,\n )}\n `,\n );\n }\n}\n","import { execa } from 'execa';\nimport { normalizeNewlines } from '../util/crossPlatform';\n\nexport const title = 'Prettier';\n\nexport default async function prettierCheck() {\n try {\n await execa({\n // Execute binaries in ./node_modules/.bin to avoid pnpm overhead\n // https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries\n preferLocal: true,\n })`prettier \"**/*.{js,jsx,ts,tsx,css,scss,sql}\" --list-different --end-of-line auto`;\n } catch (error) {\n const { stdout, stderr } = error as { stdout: string; stderr: string };\n\n if (!stdout || stderr) {\n throw error;\n }\n\n const unformattedFiles = normalizeNewlines(stdout).split('\\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 For each of the files above, open the file in your editor and save the file. This will format the file with Prettier, which will cause changes to appear in Git.\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 { sep } from 'node:path';\nimport { execa } from 'execa';\nimport { LintResult } from 'stylelint';\n\nexport const supportedStylelintFileExtensions = [\n 'css',\n 'sass',\n 'scss',\n 'less',\n 'js',\n 'tsx',\n 'jsx',\n];\n\nexport const title = 'Stylelint';\n\nexport default async function stylelintCheck() {\n try {\n await execa({\n // Execute binaries in ./node_modules/.bin to avoid pnpm overhead\n // https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries\n preferLocal: true,\n })`stylelint **/*.{${supportedStylelintFileExtensions.join(\n ',',\n )}} --max-warnings 0 --formatter json`;\n } catch (error) {\n const { stdout } = error as { stdout: string };\n\n let stylelintResults;\n\n try {\n stylelintResults = (JSON.parse(stdout) as LintResult[]).filter(\n (stylelintResult) => stylelintResult.errored === true,\n );\n } catch {\n throw error;\n }\n\n if (\n stylelintResults.length < 1 ||\n !stylelintResults.every((result) => 'errored' in result)\n ) {\n throw new Error(\n `Unexpected shape of Stylelint JSON related to .errored properties - please report this to the UpLeveled engineering team, including the following output:\n ${stdout}\n `,\n );\n }\n\n throw new Error(\n `Stylelint problems found in the following files:\n ${stylelintResults\n // Make paths relative to the project:\n //\n // Before:\n // macOS / Linux: /home/projects/random-color-generator-react-app/src/index.css\n // Windows: C:\\Users\\Lukas\\projects\\random-color-generator-react-app\\src\\index.css\n //\n // After:\n // macOS / Linux: src/index.css\n // Windows: src\\index.css\n .map(({ source }) => source!.replace(`${process.cwd()}${sep}`, ''))\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 { supportedStylelintFileExtensions } from './stylelint';\n\nconst require = createRequire(`${process.cwd()}/`);\n\nexport const title = 'Stylelint config is latest version';\n\nexport default async function stylelintConfigIsValid() {\n const { stdout: remoteVersion } =\n await execa`npm show stylelint-config-upleveled version`;\n\n let localVersion: string | undefined;\n\n try {\n const stylelintConfigPackageJsonPath = require.resolve(\n 'stylelint-config-upleveled/package.json',\n );\n\n localVersion = JSON.parse(\n await fs.readFile(stylelintConfigPackageJsonPath, 'utf-8'),\n ).version;\n } catch {\n // Swallow error\n }\n\n if (typeof localVersion === 'undefined') {\n throw new Error(\n `The UpLeveled Stylelint Config has not been installed - please install using the instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n if (semver.gt(remoteVersion, localVersion)) {\n throw new Error(\n `Your current version of the UpLeveled Stylelint Config (${localVersion}) is older than the latest version ${remoteVersion} - upgrade by running:\n\n pnpm add stylelint-config-upleveled@${remoteVersion}`,\n );\n }\n\n let stylelintConfigMatches;\n\n try {\n stylelintConfigMatches =\n (await fs.readFile('./stylelint.config.js', 'utf-8')).trim() ===\n `/** @type {import('stylelint').Config} */\nconst config = {\n extends: ['stylelint-config-upleveled'],\n};\n\nexport default config;`;\n } catch {\n throw new Error(\n `Error reading your stylelint.config.js file - please delete the file if it exists and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n if (!stylelintConfigMatches) {\n throw new Error(\n `Your stylelint.config.js file does not match the configuration file template - please delete the file and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled\n `,\n );\n }\n\n const stylelintDisableOccurrences = [];\n\n for await (const { path } of readdirp('.', {\n directoryFilter: ['!.git', '!.next', '!node_modules'],\n fileFilter: supportedStylelintFileExtensions.map(\n (fileExtension) => `*.${fileExtension}`,\n ),\n })) {\n const fileContents = await fs.readFile(path, 'utf-8');\n if (fileContents.includes('stylelint-disable')) {\n stylelintDisableOccurrences.push(path);\n }\n }\n\n if (stylelintDisableOccurrences.length > 0) {\n throw new Error(\n `Stylelint has been disabled in the following files:\n ${stylelintDisableOccurrences.join('\\n')}\n\n Remove all comments disabling or modifying Stylelint rule configuration (eg. stylelint-disable and stylelint-disable-next-line comments) and fix the problems\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`git ls-files package-lock.json yarn.lock`;\n\n if (stdout !== '') {\n throw new Error(\n `package-lock.json or yarn.lock 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 another package manager was used in addition to pnpm (eg. \"npm install\" or \"yarn add\" was run). In order to avoid issues with the state of the pnpm-lock.yaml file, we suggest also forcing regeneration this file with the following command:\n\n ${commandExample('pnpm install --force')}\n `,\n );\n }\n}\n","import { Listr, ListrTask } 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 stylelint from './checks/stylelint.js';\nimport * as stylelintConfigIsValid from './checks/stylelintConfigIsValid.js';\nimport * as useSinglePackageManager from './checks/useSinglePackageManager.js';\nimport { CtxParam } from './types/CtxParam.js';\nimport { TaskParam } from './types/TaskParam.js';\nimport {\n preflightPackageJson,\n projectPackageJson,\n} from './util/packageJson.js';\n\nconst projectDependencies = projectPackageJson.dependencies || {};\n\nconsole.log(`🚀 UpLeveled Preflight v${preflightPackageJson.version}`);\n\nconst listrTasks: ListrTask[] = [\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 ...(!(\n '@upleveled/react-scripts' in projectDependencies ||\n 'next' in projectDependencies\n )\n ? []\n : [stylelint]),\n prettier,\n\n // Version and configuration checks\n eslintConfigIsValid,\n ...(!(\n '@upleveled/react-scripts' in projectDependencies ||\n 'next' in projectDependencies\n )\n ? []\n : [stylelintConfigIsValid]),\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\nconst tasks = new Listr(listrTasks, {\n exitOnError: false,\n collectErrors: 'minimal',\n rendererOptions: {\n collapseErrors: false,\n removeEmptyLines: false,\n formatOutput: 'wrap',\n },\n fallbackRenderer: 'verbose',\n concurrent: 5,\n});\n\nawait tasks.run();\n\nif (tasks.errors.length > 0) {\n process.exit(1);\n}\n"],"names":["emptyBrailleCharacter","commandExample","command","chalk","dim","isDrone","stdout","execa","reject","test","title","allChangesCommittedToGit","replSlug","isRunningInReplIt","fs","writeFile","onlyPnpmLockModifiedOnDrone","trim","Error","eslintCheck","preferLocal","error","eslintResults","JSON","parse","filter","eslintResult","errorCount","warningCount","length","every","result","map","filePath","replace","process","cwd","sep","join","require","createRequire","eslintConfigIsValid","remoteVersion","localVersion","eslintConfigPackageJsonPath","resolve","readFile","version","semver","gt","eslintConfigMatches","eslintDisableOccurrences","path","readdirp","directoryFilter","fileFilter","fileContents","push","randomUserAgent","randomIndex","Math","floor","random","userAgents","linkOnGithubAbout","repoUrl","html","fetch","text","$","cheerio","load","urlInAboutSection","nextAll","children","next","attr","response","headers","ok","status","statusText","CRLF","normalizeNewlines","input","TypeError","RegExp","nodeModulesIgnoredFromGit","nodeModulesInGitignore","split","reduce","found","line","projectPackageJson","preflightPackageJson","URL","import","meta","url","client","algoliasearch","index","initIndex","noDependenciesWithoutTypes","dependenciesWithMissingTypes","pReduce","Object","keys","dependencies","filteredDependencies","dependency","packageJsonPath","modulePackageJson","indexDTsPath","existsSync","results","getObject","attributesToRetrieve","message","definitelyTypedPackageName","_results$types","types","definitelyTyped","devDependencies","includes","preflightBinPath","dirname","fileURLToPath","noUnusedAndMissingDependencies","ignoredPackagePatterns","startsWith","unusedDependenciesStdout","missingDependenciesStdout","messages","str","noExtraneousFilesCommittedToGit","noSecretsCommittedToGit","preflightIsLatestVersion","os","platform","prettierCheck","stderr","unformattedFiles","projectFolderNameMatchesCorrectFormat","currentDirectoryName","basename","lowercaseHyphenedDirectoryName","toLowerCase","replaceAll","supportedStylelintFileExtensions","stylelintCheck","stylelintResults","stylelintResult","errored","source","stylelintConfigIsValid","stylelintConfigPackageJsonPath","stylelintConfigMatches","stylelintDisableOccurrences","fileExtension","useSinglePackageManager","projectDependencies","console","log","listrTasks","task","ctx","newListr","eslint","stylelint","prettier","module","default","tasks","Listr","exitOnError","collectErrors","rendererOptions","collapseErrors","removeEmptyLines","formatOutput","fallbackRenderer","concurrent","run","errors","exit"],"mappings":";;;;;;;;;;;;;;;;AAEA;AACA;AACA,MAAMA,qBAAqB,GAAG,GAAG;SAEjBC,cAAcA,CAACC,OAAe;EAC5C,UAAUF,0BAA0BG,KAAK,CAACC,GAAG,CAAC,GAAG,KAAKF,SAAS;AACjE;;ACNO,eAAeG,OAAOA;EAC3B,MAAM;IAAEC;GAAQ,GAAG,MAAMC,KAAK,CAAC;IAC7BC,MAAM,EAAE;GACT,sBAAsB;EACvB,OAAO,cAAc,CAACC,IAAI,CAACH,MAAM,CAAC;AACpC;;ACFO,MAAMI,KAAK,GAAG,8BAA8B;AAEnD,AAAe,eAAeC,wBAAwBA;EACpD,MAAM;IAAEL,MAAM,EAAEM;GAAU,GAAG,MAAML,sBAAsB;EAEzD,MAAMM,iBAAiB,GAAGD,QAAQ,KAAK,EAAE;EAEzC,IAAIC,iBAAiB,EAAE;IACrB,MAAMC,QAAE,CAACC,SAAS,CAAC,mBAAmB,EAAE,WAAW,CAAC;;EAGtD,MAAM;IAAET;GAAQ,GAAG,MAAMC,6BAA6B;EAEtD,IAAID,MAAM,KAAK,EAAE,EAA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S;EACxBC,eAAe,EAAE;IACfC,cAAc,EAAE,KAAK;IACrBC,gBAAgB,EAAE,KAAK;IACvBC,YAAY,EAAE;GACf;EACDC,gBAAgB,EAAE,SAAS;EAC3BC,UAAU,EAAE;CACb,CAAC;AAEF,MAAMT,KAAK,CAACU,GAAG,EAAE;AAEjB,IAAIV,KAAK,CAACW,MAAM,CAAC3J,MAAM,GAAG,CAAC,EAAE;EAC3BM,OAAO,CAACsJ,IAAI,CAAC,CAAC,CAAC;AACjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upleveled/preflight",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.5",
|
|
4
4
|
"repository": "upleveled/preflight",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "UpLeveled (https://github.com/upleveled)",
|
|
@@ -26,38 +26,38 @@
|
|
|
26
26
|
]
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@types/eslint": "8.56.
|
|
29
|
+
"@types/eslint": "8.56.10",
|
|
30
30
|
"algoliasearch": "4.23.3",
|
|
31
31
|
"chalk": "5.3.0",
|
|
32
32
|
"cheerio": "1.0.0-rc.12",
|
|
33
33
|
"depcheck": "1.4.7",
|
|
34
34
|
"domhandler": "5.0.3",
|
|
35
|
-
"execa": "
|
|
35
|
+
"execa": "9.1.0",
|
|
36
36
|
"listr2": "8.2.1",
|
|
37
37
|
"node-fetch": "3.3.2",
|
|
38
38
|
"p-reduce": "3.0.0",
|
|
39
39
|
"patch-package": "8.0.0",
|
|
40
40
|
"readdirp": "3.6.0",
|
|
41
|
-
"semver": "7.6.
|
|
42
|
-
"top-user-agents": "2.1.
|
|
41
|
+
"semver": "7.6.2",
|
|
42
|
+
"top-user-agents": "2.1.22"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@babel/plugin-transform-modules-commonjs": "7.24.
|
|
45
|
+
"@babel/plugin-transform-modules-commonjs": "7.24.6",
|
|
46
46
|
"@jest/globals": "29.7.0",
|
|
47
|
-
"@size-limit/file": "11.1.
|
|
47
|
+
"@size-limit/file": "11.1.4",
|
|
48
48
|
"@types/babel__core": "7.20.5",
|
|
49
49
|
"@types/jest": "29.5.12",
|
|
50
|
-
"@types/node": "20.12.
|
|
50
|
+
"@types/node": "20.12.13",
|
|
51
51
|
"@types/p-map": "2.0.0",
|
|
52
52
|
"@types/semver": "7.5.8",
|
|
53
53
|
"babel-jest": "29.7.0",
|
|
54
|
-
"eslint": "9.
|
|
55
|
-
"eslint-config-upleveled": "8.
|
|
54
|
+
"eslint": "9.3.0",
|
|
55
|
+
"eslint-config-upleveled": "8.1.9",
|
|
56
56
|
"p-map": "7.0.2",
|
|
57
57
|
"postinstall-postinstall": "2.1.0",
|
|
58
58
|
"prettier": "3.2.5",
|
|
59
|
-
"size-limit": "11.1.
|
|
60
|
-
"stylelint": "16.
|
|
59
|
+
"size-limit": "11.1.4",
|
|
60
|
+
"stylelint": "16.6.1",
|
|
61
61
|
"tsdx": "0.14.1",
|
|
62
62
|
"tslib": "2.6.2",
|
|
63
63
|
"typescript": "5.4.5"
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
|
-
import {
|
|
2
|
+
import { execa } from 'execa';
|
|
3
3
|
import { commandExample } from '../util/commandExample';
|
|
4
4
|
import { isDrone } from '../util/drone';
|
|
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 execa`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 execa`git status --porcelain`;
|
|
18
18
|
|
|
19
19
|
if (stdout !== '') {
|
|
20
20
|
const onlyPnpmLockModifiedOnDrone =
|
package/src/checks/eslint.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { sep } from 'node:path';
|
|
2
2
|
import { ESLint } from 'eslint';
|
|
3
|
-
import {
|
|
3
|
+
import { execa } from 'execa';
|
|
4
4
|
|
|
5
5
|
export const title = 'ESLint';
|
|
6
6
|
|
|
7
7
|
export default async function eslintCheck() {
|
|
8
8
|
try {
|
|
9
|
-
await
|
|
9
|
+
await execa({
|
|
10
|
+
// Execute binaries in ./node_modules/.bin to avoid pnpm overhead
|
|
11
|
+
// https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries
|
|
12
|
+
preferLocal: true,
|
|
13
|
+
})`eslint . --max-warnings 0 --format json`;
|
|
10
14
|
} catch (error) {
|
|
11
15
|
const { stdout } = error as { stdout: string };
|
|
12
16
|
|
|
@@ -19,7 +23,7 @@ export default async function eslintCheck() {
|
|
|
19
23
|
.filter((eslintResult) => {
|
|
20
24
|
return eslintResult.errorCount > 0 || eslintResult.warningCount > 0;
|
|
21
25
|
});
|
|
22
|
-
} catch
|
|
26
|
+
} catch {
|
|
23
27
|
throw error;
|
|
24
28
|
}
|
|
25
29
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import {
|
|
3
|
+
import { execa } from 'execa';
|
|
4
4
|
import readdirp from 'readdirp';
|
|
5
5
|
import semver from 'semver';
|
|
6
6
|
|
|
@@ -9,9 +9,8 @@ const require = createRequire(`${process.cwd()}/`);
|
|
|
9
9
|
export const title = 'ESLint config is latest version';
|
|
10
10
|
|
|
11
11
|
export default async function eslintConfigIsValid() {
|
|
12
|
-
const { stdout: remoteVersion } =
|
|
13
|
-
|
|
14
|
-
);
|
|
12
|
+
const { stdout: remoteVersion } =
|
|
13
|
+
await execa`npm show eslint-config-upleveled version`;
|
|
15
14
|
|
|
16
15
|
let localVersion: string | undefined;
|
|
17
16
|
|
|
@@ -23,7 +22,9 @@ export default async function eslintConfigIsValid() {
|
|
|
23
22
|
localVersion = JSON.parse(
|
|
24
23
|
await fs.readFile(eslintConfigPackageJsonPath, 'utf-8'),
|
|
25
24
|
).version;
|
|
26
|
-
} catch
|
|
25
|
+
} catch {
|
|
26
|
+
// Swallow error
|
|
27
|
+
}
|
|
27
28
|
|
|
28
29
|
if (typeof localVersion === 'undefined') {
|
|
29
30
|
throw new Error(
|
|
@@ -45,7 +46,7 @@ export default async function eslintConfigIsValid() {
|
|
|
45
46
|
eslintConfigMatches =
|
|
46
47
|
(await fs.readFile('./eslint.config.js', 'utf-8')).trim() ===
|
|
47
48
|
"export { default } from 'eslint-config-upleveled';";
|
|
48
|
-
} catch
|
|
49
|
+
} catch {
|
|
49
50
|
throw new Error(
|
|
50
51
|
`Error reading your eslint.config.js file - please delete the file if it exists and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled
|
|
51
52
|
`,
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import cheerio from 'cheerio';
|
|
2
2
|
import type { Element } from 'domhandler';
|
|
3
|
-
import {
|
|
3
|
+
import { execa } 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 execa`git remote get-url origin`;
|
|
11
11
|
|
|
12
12
|
const repoUrl = stdout
|
|
13
13
|
.replace('git@github.com:', 'https://github.com/')
|
|
@@ -44,13 +44,17 @@ export default async function noDependenciesWithoutTypes() {
|
|
|
44
44
|
if ('types' in modulePackageJson || 'typings' in modulePackageJson) {
|
|
45
45
|
return filteredDependencies;
|
|
46
46
|
}
|
|
47
|
-
} catch
|
|
47
|
+
} catch {
|
|
48
|
+
// Swallow error
|
|
49
|
+
}
|
|
48
50
|
|
|
49
51
|
let indexDTsPath;
|
|
50
52
|
|
|
51
53
|
try {
|
|
52
54
|
indexDTsPath = require.resolve(`${dependency}/index.d.ts`);
|
|
53
|
-
} catch
|
|
55
|
+
} catch {
|
|
56
|
+
// Swallow error
|
|
57
|
+
}
|
|
54
58
|
|
|
55
59
|
// If the index.d.ts file exists inside the module's directory, bail out
|
|
56
60
|
if (indexDTsPath && existsSync(indexDTsPath)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execa } from 'execa';
|
|
2
2
|
import { commandExample } from '../../util/commandExample';
|
|
3
3
|
import { preflightBinPath } from '../../util/preflightBinPath';
|
|
4
4
|
|
|
@@ -61,9 +61,7 @@ export default async function noUnusedAndMissingDependencies() {
|
|
|
61
61
|
].join(',');
|
|
62
62
|
|
|
63
63
|
try {
|
|
64
|
-
await
|
|
65
|
-
`${preflightBinPath}/depcheck --ignores="${ignoredPackagePatterns}"`,
|
|
66
|
-
);
|
|
64
|
+
await execa`${preflightBinPath}/depcheck --ignores="${ignoredPackagePatterns}"`;
|
|
67
65
|
} catch (error) {
|
|
68
66
|
const { stdout } = error as { stdout: string };
|
|
69
67
|
if (
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execa } 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 } =
|
|
8
|
-
|
|
9
|
-
);
|
|
7
|
+
const { stdout } =
|
|
8
|
+
await execa`git ls-files .DS_Store yarn-error.log npm-debug.log`;
|
|
10
9
|
|
|
11
10
|
if (stdout !== '') {
|
|
12
11
|
throw new Error(
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execa } 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 execa`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 { execa } from 'execa';
|
|
3
3
|
import { commandExample } from '../util/commandExample';
|
|
4
4
|
import { normalizeNewlines } from '../util/crossPlatform';
|
|
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 execa`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,7 +15,7 @@ export default async function nodeModulesIgnoredFromGit() {
|
|
|
15
15
|
);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
if ((await
|
|
18
|
+
if ((await execa`git ls-files .gitignore`).stdout !== '.gitignore') {
|
|
19
19
|
throw new Error('.gitignore file not found');
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
|
-
import {
|
|
2
|
+
import { execa } from 'execa';
|
|
3
3
|
import semver from 'semver';
|
|
4
4
|
import { commandExample } from '../util/commandExample';
|
|
5
5
|
import { preflightPackageJson } from '../util/packageJson';
|
|
@@ -7,9 +7,8 @@ import { preflightPackageJson } from '../util/packageJson';
|
|
|
7
7
|
export const title = 'Preflight is latest version';
|
|
8
8
|
|
|
9
9
|
export default async function preflightIsLatestVersion() {
|
|
10
|
-
const { stdout: remoteVersion } =
|
|
11
|
-
|
|
12
|
-
);
|
|
10
|
+
const { stdout: remoteVersion } =
|
|
11
|
+
await execa`npm show @upleveled/preflight version`;
|
|
13
12
|
|
|
14
13
|
if (semver.gt(remoteVersion, preflightPackageJson.version)) {
|
|
15
14
|
throw new Error(
|
package/src/checks/prettier.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execa } from 'execa';
|
|
2
2
|
import { normalizeNewlines } from '../util/crossPlatform';
|
|
3
3
|
|
|
4
4
|
export const title = 'Prettier';
|
|
5
5
|
|
|
6
6
|
export default async function prettierCheck() {
|
|
7
7
|
try {
|
|
8
|
-
await
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
await execa({
|
|
9
|
+
// Execute binaries in ./node_modules/.bin to avoid pnpm overhead
|
|
10
|
+
// https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries
|
|
11
|
+
preferLocal: true,
|
|
12
|
+
})`prettier "**/*.{js,jsx,ts,tsx,css,scss,sql}" --list-different --end-of-line auto`;
|
|
11
13
|
} catch (error) {
|
|
12
14
|
const { stdout, stderr } = error as { stdout: string; stderr: string };
|
|
13
15
|
|
package/src/checks/stylelint.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { sep } from 'node:path';
|
|
2
|
-
import {
|
|
2
|
+
import { execa } from 'execa';
|
|
3
3
|
import { LintResult } from 'stylelint';
|
|
4
4
|
|
|
5
5
|
export const supportedStylelintFileExtensions = [
|
|
@@ -16,11 +16,13 @@ export const title = 'Stylelint';
|
|
|
16
16
|
|
|
17
17
|
export default async function stylelintCheck() {
|
|
18
18
|
try {
|
|
19
|
-
await
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
)
|
|
19
|
+
await execa({
|
|
20
|
+
// Execute binaries in ./node_modules/.bin to avoid pnpm overhead
|
|
21
|
+
// https://github.com/sindresorhus/execa/blob/main/docs/environment.md#local-binaries
|
|
22
|
+
preferLocal: true,
|
|
23
|
+
})`stylelint **/*.{${supportedStylelintFileExtensions.join(
|
|
24
|
+
',',
|
|
25
|
+
)}} --max-warnings 0 --formatter json`;
|
|
24
26
|
} catch (error) {
|
|
25
27
|
const { stdout } = error as { stdout: string };
|
|
26
28
|
|
|
@@ -30,7 +32,7 @@ export default async function stylelintCheck() {
|
|
|
30
32
|
stylelintResults = (JSON.parse(stdout) as LintResult[]).filter(
|
|
31
33
|
(stylelintResult) => stylelintResult.errored === true,
|
|
32
34
|
);
|
|
33
|
-
} catch
|
|
35
|
+
} catch {
|
|
34
36
|
throw error;
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { promises as fs } from 'node:fs';
|
|
2
2
|
import { createRequire } from 'node:module';
|
|
3
|
-
import {
|
|
3
|
+
import { execa } from 'execa';
|
|
4
4
|
import readdirp from 'readdirp';
|
|
5
5
|
import semver from 'semver';
|
|
6
6
|
import { supportedStylelintFileExtensions } from './stylelint';
|
|
@@ -10,9 +10,8 @@ const require = createRequire(`${process.cwd()}/`);
|
|
|
10
10
|
export const title = 'Stylelint config is latest version';
|
|
11
11
|
|
|
12
12
|
export default async function stylelintConfigIsValid() {
|
|
13
|
-
const { stdout: remoteVersion } =
|
|
14
|
-
|
|
15
|
-
);
|
|
13
|
+
const { stdout: remoteVersion } =
|
|
14
|
+
await execa`npm show stylelint-config-upleveled version`;
|
|
16
15
|
|
|
17
16
|
let localVersion: string | undefined;
|
|
18
17
|
|
|
@@ -24,7 +23,9 @@ export default async function stylelintConfigIsValid() {
|
|
|
24
23
|
localVersion = JSON.parse(
|
|
25
24
|
await fs.readFile(stylelintConfigPackageJsonPath, 'utf-8'),
|
|
26
25
|
).version;
|
|
27
|
-
} catch
|
|
26
|
+
} catch {
|
|
27
|
+
// Swallow error
|
|
28
|
+
}
|
|
28
29
|
|
|
29
30
|
if (typeof localVersion === 'undefined') {
|
|
30
31
|
throw new Error(
|
|
@@ -52,7 +53,7 @@ const config = {
|
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
export default config;`;
|
|
55
|
-
} catch
|
|
56
|
+
} catch {
|
|
56
57
|
throw new Error(
|
|
57
58
|
`Error reading your stylelint.config.js file - please delete the file if it exists and reinstall the config using the instructions on https://www.npmjs.com/package/eslint-config-upleveled
|
|
58
59
|
`,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execa } 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
|
|
8
|
-
'git ls-files package-lock.json yarn.lock',
|
|
9
|
-
);
|
|
7
|
+
const { stdout } = await execa`git ls-files package-lock.json yarn.lock`;
|
|
10
8
|
|
|
11
9
|
if (stdout !== '') {
|
|
12
10
|
throw new Error(
|
package/src/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ import * as eslint from './checks/eslint.js';
|
|
|
4
4
|
import * as eslintConfigIsValid from './checks/eslintConfigIsValid.js';
|
|
5
5
|
import * as linkOnGithubAbout from './checks/linkOnGithubAbout.js';
|
|
6
6
|
import * as nodeModulesIgnoredFromGit from './checks/nodeModulesIgnoredFromGit.js';
|
|
7
|
-
import * as nextJsProjectHasSharpInstalled from './checks/noDependencyProblems/nextJsProjectHasSharpInstalled.js';
|
|
8
7
|
import * as noDependenciesWithoutTypes from './checks/noDependencyProblems/noDependenciesWithoutTypes.js';
|
|
9
8
|
import * as noUnusedAndMissingDependencies from './checks/noDependencyProblems/noUnusedDependencies.js';
|
|
10
9
|
import * as noExtraneousFilesCommittedToGit from './checks/noExtraneousFilesCommittedToGit.js';
|
|
@@ -46,14 +45,6 @@ const listrTasks: ListrTask[] = [
|
|
|
46
45
|
title: 'No dependency problems',
|
|
47
46
|
task: (ctx: CtxParam, task: TaskParam): Listr =>
|
|
48
47
|
task.newListr([
|
|
49
|
-
...(!Object.keys(projectDependencies).includes('next')
|
|
50
|
-
? []
|
|
51
|
-
: [
|
|
52
|
-
{
|
|
53
|
-
title: nextJsProjectHasSharpInstalled.title,
|
|
54
|
-
task: nextJsProjectHasSharpInstalled.default,
|
|
55
|
-
},
|
|
56
|
-
]),
|
|
57
48
|
{
|
|
58
49
|
title: noUnusedAndMissingDependencies.title,
|
|
59
50
|
task: noUnusedAndMissingDependencies.default,
|
package/src/util/drone.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execa } from 'execa';
|
|
2
2
|
|
|
3
3
|
export async function isDrone() {
|
|
4
|
-
const { stdout } = await
|
|
4
|
+
const { stdout } = await execa({
|
|
5
5
|
reject: false,
|
|
6
|
-
})
|
|
6
|
+
})`cat /etc/os-release`;
|
|
7
7
|
return /Alpine Linux/.test(stdout);
|
|
8
8
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { dirname } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import {
|
|
3
|
+
import { execa } from 'execa';
|
|
4
4
|
|
|
5
|
-
export const { stdout: preflightBinPath } = await
|
|
5
|
+
export const { stdout: preflightBinPath } = await execa({
|
|
6
6
|
cwd: dirname(fileURLToPath(import.meta.url)),
|
|
7
|
-
})
|
|
7
|
+
})`pnpm bin`;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { commandExample } from '../../util/commandExample';
|
|
2
|
-
import { projectPackageJson } from '../../util/packageJson';
|
|
3
|
-
|
|
4
|
-
export const title = 'Next.js project has sharp installed';
|
|
5
|
-
|
|
6
|
-
export default function nextJsProjectHasSharpInstalled() {
|
|
7
|
-
const dependenciesPackageNames = Object.keys(
|
|
8
|
-
projectPackageJson.dependencies || {},
|
|
9
|
-
);
|
|
10
|
-
if (
|
|
11
|
-
dependenciesPackageNames.includes('next') &&
|
|
12
|
-
!dependenciesPackageNames.includes('sharp')
|
|
13
|
-
) {
|
|
14
|
-
throw new Error(
|
|
15
|
-
`Next.js projects should have sharp installed for better image optimization. Install it with:
|
|
16
|
-
|
|
17
|
-
${commandExample('pnpm add sharp')}
|
|
18
|
-
`,
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
}
|