diff --git a/build/generate-typedoc-readme.mjs b/build/generate-typedoc-readme.mjs index 35b5996a9..3a834cb0f 100644 --- a/build/generate-typedoc-readme.mjs +++ b/build/generate-typedoc-readme.mjs @@ -1,5 +1,3 @@ -#!/usr/bin/env node - /** * Generates README files for typedoc */ diff --git a/build/mocha-reporter.js b/build/mocha-reporter.js index 6b1137356..5d7fd29e7 100644 --- a/build/mocha-reporter.js +++ b/build/mocha-reporter.js @@ -19,7 +19,7 @@ module.exports = class MultiReporter extends BaseReporter { } else { new JsonReporter(runner, { reporterOption: { - output: `reports/mocha.json`, + output: 'reports/mocha.json', }, }); } @@ -59,7 +59,7 @@ function CypressJsonReporter(runner, options) { tests: tests.map(clean), pending: pending.map(clean), failures: failures.map(clean), - passes: passes.map(clean) + passes: passes.map(clean), }; const json = JSON.stringify(obj, null, 2); const output = options.reporterOption.output; @@ -80,7 +80,7 @@ function CypressJsonReporter(runner, options) { duration: test.duration, currentRetry: test.currentRetry(), speed: test.speed, - err: cleanCycles(err) + err: cleanCycles(err), }; } diff --git a/build/plugins/esbuild-plugin-budget.ts b/build/plugins/esbuild-plugin-budget.ts index cc3b4ff9e..a488b6199 100644 --- a/build/plugins/esbuild-plugin-budget.ts +++ b/build/plugins/esbuild-plugin-budget.ts @@ -19,7 +19,8 @@ export function budgetPlugin(budget: string): Plugin { const file = result.outputFiles.find((f) => f.path.endsWith(filename)); if (file) { if (file.contents.length > maxsize) { - throw chalk.red(`File ${filename} exceeds budget of ${budget}, current size: ${Math.round(file.contents.length / 1024)}kb`); + const size = Math.round(file.contents.length / 1024); + throw chalk.red(`File ${filename} exceeds budget of ${budget}, current size: ${size}kb`); } } }); diff --git a/build/prepare-changelog.mjs b/build/prepare-changelog.mjs index 3baeaea94..37597915f 100644 --- a/build/prepare-changelog.mjs +++ b/build/prepare-changelog.mjs @@ -1,5 +1,3 @@ -#!/usr/bin/env node - /** * Generate the release note */ diff --git a/build/prepare-package.mjs b/build/prepare-package.mjs index 35b319688..a094ff442 100644 --- a/build/prepare-package.mjs +++ b/build/prepare-package.mjs @@ -1,5 +1,3 @@ -#!/usr/bin/env node - /** * Copy the contents of each package "dist" folders to a root "dist" folder * In order to prepare the creation of the release ZIP diff --git a/build/select-packages.mjs b/build/select-packages.mjs index 8fbc40539..a3f6a161c 100644 --- a/build/select-packages.mjs +++ b/build/select-packages.mjs @@ -1,3 +1,8 @@ +/** + * Prompts for the packages to use + * Returns the '--filter' arguments for Turbo + */ + import fs from 'fs'; import inquirer from 'inquirer'; import process from 'process'; @@ -18,19 +23,9 @@ prompt([ name: 'packages', message: 'Select which packages to build', type: 'checkbox', - choices: [ - { value: 'core', checked: true }, - ...packages, - ], - } -]) - .then((answers) => { - const filters = [ - '//', - ...answers.packages, - ] - .map(p => `--filter=${p}`) - .join(' '); - - process.stdout.write(filters); - }); \ No newline at end of file + choices: [{ value: 'core', checked: true }, ...packages], + }, +]).then((answers) => { + const filters = ['//', ...answers.packages].map((p) => `--filter=${p}`).join(' '); + process.stdout.write(filters); +}); diff --git a/build/start-and-test.mjs b/build/start-and-test.mjs index 082ee64db..4e60df90a 100644 --- a/build/start-and-test.mjs +++ b/build/start-and-test.mjs @@ -1,3 +1,7 @@ +/** + * Starts the server (first argument), launches the tests (second argument), then close the server + */ + import { spawn } from 'child_process'; const SERVE_SCRIPT = process.argv[2]; diff --git a/build/templates/npmrc.ts b/build/templates/npmrc.ts index dd7e592e2..03ce7da6c 100644 --- a/build/templates/npmrc.ts +++ b/build/templates/npmrc.ts @@ -1,4 +1,4 @@ export const npmrc = () => -`@photo-sphere-viewer:registry=https://registry.npmjs.org + `@photo-sphere-viewer:registry=https://registry.npmjs.org //registry.npmjs.org/:_authToken=\${NODE_AUTH_TOKEN} `; diff --git a/build/templates/package.ts b/build/templates/package.ts index fd2012220..93b1a7f93 100644 --- a/build/templates/package.ts +++ b/build/templates/package.ts @@ -18,12 +18,7 @@ export const packageJson = (pkg: any) => { email: 'contact@git.strangeplanet.fr', homepage: 'https://www.strangeplanet.fr', }, - keywords: [ - 'photosphere', - 'panorama', - 'threejs', - ...(pkg.keywords || []), - ], + keywords: ['photosphere', 'panorama', 'threejs', ...(pkg.keywords || [])], }; if (pkg.psv.style) { diff --git a/build/templates/readme.ts b/build/templates/readme.ts index 618898466..2676392f5 100644 --- a/build/templates/readme.ts +++ b/build/templates/readme.ts @@ -1,5 +1,5 @@ -export const readme = (pkg: any) => -`# ${pkg.psv.title} +export const readme = (pkg: any) => + `# ${pkg.psv.title} [![NPM version](https://img.shields.io/npm/v/${pkg.name}?logo=npm)](https://www.npmjs.com/package/${pkg.name}) [![NPM Downloads](https://img.shields.io/npm/dm/${pkg.name}?color=f86036&label=npm&logo=npm)](https://www.npmjs.com/package/${pkg.name}) diff --git a/build/tsup.config.ts b/build/tsup.config.ts index 92aab408e..23dcbb18c 100644 --- a/build/tsup.config.ts +++ b/build/tsup.config.ts @@ -12,8 +12,9 @@ import { readme } from './templates/readme'; export default function createConfig(pkg: any) { const banner = `/*! * ${pkg.psv.title} ${pkg.version} -${pkg.name === '@photo-sphere-viewer/core' ? ' * @copyright 2014-2015 Jérémy Heleine\n' : '' - } * @copyright 2015-${new Date().getFullYear()} Damien "Mistic" Sorel +${ + pkg.name === '@photo-sphere-viewer/core' ? ' * @copyright 2014-2015 Jérémy Heleine\n' : '' +} * @copyright 2015-${new Date().getFullYear()} Damien "Mistic" Sorel * @licence MIT (https://opensource.org/licenses/MIT) */`; @@ -45,14 +46,14 @@ ${pkg.name === '@photo-sphere-viewer/core' ? ' * @copyright 2014-2015 Jérémy H ...(dev ? [] : [ - scssBundlePlugin(), - assetsPlugin({ - 'LICENSE': license(), - '.npmrc': npmrc(), - 'README.md': readme(pkg), - 'package.json': packageJson(pkg), - }), - ]), + scssBundlePlugin(), + assetsPlugin({ + 'LICENSE': license(), + '.npmrc': npmrc(), + 'README.md': readme(pkg), + 'package.json': packageJson(pkg), + }), + ]), ], esbuildOptions(options) { options.banner = { diff --git a/build/update-issue-templates.mjs b/build/update-issue-templates.mjs index 86003587b..e32ecf505 100644 --- a/build/update-issue-templates.mjs +++ b/build/update-issue-templates.mjs @@ -1,5 +1,3 @@ -#!/usr/bin/env node - /** * Add the version provided as first parameter to the options of the issue templates */ @@ -16,38 +14,34 @@ if (!VERSION) { process.exit(0); } -[ - '.github/ISSUE_TEMPLATE/bug_report.yml', - '.github/ISSUE_TEMPLATE/support_request.yml', -] - .forEach((filename) => { - if (!fs.existsSync(filename)) { - console.warn(`${filename} does not exists`); - return; - } - - const content = yaml.parse(fs.readFileSync(filename, { encoding: 'utf8' })); - - const item = content.body.find(({ id }) => id === 'version'); - if (!item) { - console.warn(`Dropdown not found in ${filename}`); - return; - } - - const versions = item.attributes.options.filter((v) => v !== OTHER_LABEL); - if (versions.indexOf(VERSION) !== -1) { - console.warn(`Version ${VERSION} already exists in ${filename}`); - return; - } - - console.log(`Add ${VERSION} in ${filename}`); - versions.unshift(VERSION); - if (versions.length > MAX_VERSIONS) { - versions.splice(MAX_VERSIONS, versions.length - MAX_VERSIONS); - } - versions.push(OTHER_LABEL); - - item.attributes.options = versions; - - fs.writeFileSync(filename, yaml.stringify(content, { lineWidth: 0 })); - }); +['.github/ISSUE_TEMPLATE/bug_report.yml', '.github/ISSUE_TEMPLATE/support_request.yml'].forEach((filename) => { + if (!fs.existsSync(filename)) { + console.warn(`${filename} does not exists`); + return; + } + + const content = yaml.parse(fs.readFileSync(filename, { encoding: 'utf8' })); + + const item = content.body.find(({ id }) => id === 'version'); + if (!item) { + console.warn(`Dropdown not found in ${filename}`); + return; + } + + const versions = item.attributes.options.filter((v) => v !== OTHER_LABEL); + if (versions.indexOf(VERSION) !== -1) { + console.warn(`Version ${VERSION} already exists in ${filename}`); + return; + } + + console.log(`Add ${VERSION} in ${filename}`); + versions.unshift(VERSION); + if (versions.length > MAX_VERSIONS) { + versions.splice(MAX_VERSIONS, versions.length - MAX_VERSIONS); + } + versions.push(OTHER_LABEL); + + item.attributes.options = versions; + + fs.writeFileSync(filename, yaml.stringify(content, { lineWidth: 0 })); +}); diff --git a/package.json b/package.json index 80ee46b06..1c6fbd4f3 100644 --- a/package.json +++ b/package.json @@ -14,19 +14,19 @@ "lint": "turbo run lint", "test": "turbo run test", "serve": "turbo run watch --concurrency 50", - "serve:filter": "run() { read filters; turbo run watch --concurrency 50 $filters; }; FORCE_COLOR=true node build/select-packages.mjs | run", + "serve:filter": "run() { read filters; turbo run watch --concurrency 50 $filters; }; FORCE_COLOR=true node ./build/select-packages.mjs | run", "npm-link": "turbo run npm-link --output-logs=new-only", "doc:build": "turbo run build-doc --force", "doc:serve": "turbo run serve-doc", "ci:build": "turbo run lint build test --cache-dir=.turbo", "ci:build-doc": "turbo run build-doc --cache-dir=.turbo", - "ci:e2e": "node build/start-and-test.mjs \"watch --no-open\" e2e:run", + "ci:e2e": "node ./build/start-and-test.mjs \"watch --no-open\" e2e:run", "ci:version": "set-versions --workspaces", "ci:publish": "turbo run publish-dist --concurrency=1", "e2e:open": "cypress open --e2e --browser=electron", "e2e:run": "cypress run --e2e --browser=electron", "build-doc": "node ./build/generate-typedoc-readme.mjs && typedoc --plugin typedoc-plugin-extras --out public/api", - "watch": "node build/liveserver.mjs" + "watch": "node ./build/liveserver.mjs" }, "devDependencies": { "@stylistic/stylelint-plugin": "^3.1.0",