Skip to content

Commit

Permalink
chore: update bins
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Oct 21, 2024
1 parent 3150842 commit 8fda3c7
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 85 deletions.
2 changes: 0 additions & 2 deletions build/generate-typedoc-readme.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

/**
* Generates README files for typedoc
*/
Expand Down
6 changes: 3 additions & 3 deletions build/mocha-reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = class MultiReporter extends BaseReporter {
} else {
new JsonReporter(runner, {
reporterOption: {
output: `reports/mocha.json`,
output: 'reports/mocha.json',
},
});
}
Expand Down Expand Up @@ -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;
Expand All @@ -80,7 +80,7 @@ function CypressJsonReporter(runner, options) {
duration: test.duration,
currentRetry: test.currentRetry(),
speed: test.speed,
err: cleanCycles(err)
err: cleanCycles(err),
};
}

Expand Down
3 changes: 2 additions & 1 deletion build/plugins/esbuild-plugin-budget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
}
});
Expand Down
2 changes: 0 additions & 2 deletions build/prepare-changelog.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

/**
* Generate the release note
*/
Expand Down
2 changes: 0 additions & 2 deletions build/prepare-package.mjs
Original file line number Diff line number Diff line change
@@ -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
Expand Down
27 changes: 11 additions & 16 deletions build/select-packages.mjs
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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);
});
choices: [{ value: 'core', checked: true }, ...packages],
},
]).then((answers) => {
const filters = ['//', ...answers.packages].map((p) => `--filter=${p}`).join(' ');
process.stdout.write(filters);
});
4 changes: 4 additions & 0 deletions build/start-and-test.mjs
Original file line number Diff line number Diff line change
@@ -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];
Expand Down
2 changes: 1 addition & 1 deletion build/templates/npmrc.ts
Original file line number Diff line number Diff line change
@@ -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}
`;
7 changes: 1 addition & 6 deletions build/templates/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ export const packageJson = (pkg: any) => {
email: '[email protected]',
homepage: 'https://www.strangeplanet.fr',
},
keywords: [
'photosphere',
'panorama',
'threejs',
...(pkg.keywords || []),
],
keywords: ['photosphere', 'panorama', 'threejs', ...(pkg.keywords || [])],
};

if (pkg.psv.style) {
Expand Down
4 changes: 2 additions & 2 deletions build/templates/readme.ts
Original file line number Diff line number Diff line change
@@ -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})
Expand Down
21 changes: 11 additions & 10 deletions build/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/`;

Expand Down Expand Up @@ -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 = {
Expand Down
68 changes: 31 additions & 37 deletions build/update-issue-templates.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env node

/**
* Add the version provided as first parameter to the options of the issue templates
*/
Expand All @@ -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 }));
});
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8fda3c7

Please sign in to comment.