Skip to content

Commit

Permalink
Project update. [p][robotic]
Browse files Browse the repository at this point in the history
  • Loading branch information
jaswrks committed Dec 2, 2023
1 parent a48dcb8 commit fadc61c
Show file tree
Hide file tree
Showing 46 changed files with 18,045 additions and 15,751 deletions.
28 changes: 25 additions & 3 deletions .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,33 @@
# Generated data.
# <generated:start>

# Last generated Nov 13, 2023 10:04 PM UTC.
# Last generated Dec 2, 2023 5:20 PM UTC.

[production]
last 1 chrome versions
node >= 20.9.0
and_chr >= 92
chrome >= 92
and_ff >= 90
android >= 119
edge >= 92
samsung >= 16.0
safari >= 15.4
ios_saf >= 15.4
opera >= 78
firefox >= 90
unreleased and_chr versions
unreleased chrome versions
unreleased and_ff versions
unreleased android versions
unreleased edge versions
unreleased samsung versions
unreleased safari versions
unreleased ios_saf versions
unreleased opera versions
unreleased firefox versions
not dead

[development]
node >= 20.9.0
and_chr >= 92
chrome >= 92
Expand All @@ -45,7 +68,6 @@ unreleased firefox versions
not dead

[any]
last 1 chrome versions
node >= 20.9.0
and_chr >= 92
chrome >= 92
Expand Down
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Nov 13, 2023 10:04 PM UTC.
# Last generated Dec 2, 2023 5:20 PM UTC.

# Locals

Expand Down
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Nov 13, 2023 10:04 PM UTC.
# Last generated Dec 2, 2023 5:20 PM UTC.

# Default

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Nov 13, 2023 10:04 PM UTC.
# Last generated Dec 2, 2023 5:20 PM UTC.

# Locals

Expand Down
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# Generated data.
# <generated:start>

# Last generated Nov 13, 2023 10:04 PM UTC.
# Last generated Dec 2, 2023 5:20 PM UTC.

# Locals

Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Nov 13, 2023 10:04 PM UTC.
# Last generated Dec 2, 2023 5:20 PM UTC.

# Packages

Expand Down
13 changes: 9 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @note This entire file will be updated automatically.
* @note Instead of editing here, please review `./settings.mjs`.
*
* Last generated using `./settings.mjs` Nov 13, 2023 10:04 PM UTC.
* Last generated using `./settings.mjs` Dec 2, 2023 5:20 PM UTC.
*/
{
"editor.formatOnType": false,
Expand Down Expand Up @@ -219,14 +219,15 @@
"eslint.lintTask.enable": false,
"eslint.run": "onType",
"eslint.runtime": "node",
"eslint.useESLintClass": true,
"eslint.codeActionsOnSave.mode": "all",
"eslint.experimental.useFlatConfig": true,
"eslint.workingDirectories": [
{
"mode": "auto"
}
],
"eslint.validate": ["mdx", "markdown", "javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
"eslint.options": {
"overrideConfigFile": "./eslint.config.mjs"
},
Expand Down Expand Up @@ -311,25 +312,29 @@
"markdown.preview.lineHeight": 1.5,
"markdown.preview.typographer": true,
"markdown.preview.fontFamily": "Georama, ui-sans-serif, sans-serif",
"markdown.validate.enabled": false,
"mdx.server.enable": false,
"prettier.ignorePath": ".prettierignore",
"evenBetterToml.formatter.indentString": " ",
"[mdx]": {
"editor.tabSize": 4,
"editor.insertSpaces": true,
"files.trimTrailingWhitespace": false,
"editor.wordWrap": "on",
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.tabSize": 4,
"editor.insertSpaces": true,
"files.trimTrailingWhitespace": false,
"editor.wordWrap": "on",
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[html]": {
"editor.tabSize": 4,
Expand Down
2 changes: 1 addition & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Nov 13, 2023 10:04 PM UTC.
# Last generated Dec 2, 2023 5:20 PM UTC.

# Locals

Expand Down
24 changes: 14 additions & 10 deletions dev/.files/bin/browserslist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,23 @@ export default async ({ projDir }) => {

/**
* Defines environment contents.
*
* - `production` is an established default that many tools use when `NODE_ENV=production`.
* - `development` is an established default that many tools use when `NODE_ENV=development`.
* - The other environments correlate with our target build environments.
*/
let browserslistrcFileContentsEnvs = $str.dedent(`
# Last generated ${$time.now().toProse()}.
`);
for (const targetEnv of ['production', 'any', 'node', 'cfw', 'cfp', 'web', 'webw']) {
for (const targetEnv of ['production', 'development', 'any', 'node', 'cfw', 'cfp', 'web', 'webw']) {
switch (targetEnv) {
default: {
browserslistrcFileContentsEnvs += '\n\n[' + targetEnv + ']';
}
}
switch (targetEnv) {
case 'production':
case 'any':
case 'cfw':
case 'cfp': {
browserslistrcFileContentsEnvs += '\n' + 'last 1 chrome versions';
break;
}
}
switch (targetEnv) {
case 'production':
case 'development':
case 'any':
case 'node': {
browserslistrcFileContentsEnvs += '\n' + 'node >= ' + nodeVersion.current;
Expand All @@ -55,13 +51,21 @@ export default async ({ projDir }) => {
}
switch (targetEnv) {
case 'production':
case 'development':
case 'any':
case 'web':
case 'webw': {
browserslistrcFileContentsEnvs += '\n' + browsersWithSupportForEcmaVersion(esVersion.lcnYear).join('\n');
break;
}
}
switch (targetEnv) {
case 'cfw':
case 'cfp': {
browserslistrcFileContentsEnvs += '\n' + 'last 1 chrome versions';
break;
}
}
switch (targetEnv) {
default: {
browserslistrcFileContentsEnvs += '\n' + 'not dead';
Expand Down
41 changes: 41 additions & 0 deletions dev/.files/bin/includes/import-aliases.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,72 @@
* @note Instead of editing here, please review <https://github.com/clevercanyon/skeleton>.
*/

import fs from 'node:fs';
import path from 'node:path';
import { $fs } from '../../../../node_modules/@clevercanyon/utilities.node/dist/index.js';
import { $is, $json, $str } from '../../../../node_modules/@clevercanyon/utilities/dist/index.js';

const __dirname = $fs.imuDirname(import.meta.url);
const projDir = path.resolve(__dirname, '../../../..');

const pkgFile = path.resolve(projDir, './package.json');
const pkg = $json.parse(fs.readFileSync(pkgFile).toString());

/**
* Parses userland aliases.
*/
const userlandAliasesAsGlobs = {};
const userlandAliasesAsRegExpStrings = {};
const userlandAliasesAsFindReplaceRegExps = [];

for (const [glob, relPath] of Object.entries(pkg.imports || {})) {
// We do not allow nesting and/or any subpath conditionals.
if (!$is.string(relPath)) throw new Error('Invalid subpath imports.');

let regExpRepCounter = 0; // e.g., `$1`, `$2`, `$3`, etc.
const regExpString = '^' + $str.escRegExp(glob).replace(/\\\*/gu, '(.+?)') + '$';

userlandAliasesAsGlobs[glob] = path.resolve(projDir, relPath);
userlandAliasesAsRegExpStrings[regExpString] = path.resolve(projDir, relPath).replace(/\*/gu, () => '$' + String(++regExpRepCounter));
userlandAliasesAsFindReplaceRegExps.push({ find: new RegExp(regExpString, 'u'), replacement: userlandAliasesAsRegExpStrings[regExpString] });
}

/**
* Defines import aliases.
*
* Userland aliases; i.e., node subpath imports, begin with `#` and are defined in `./package.json`, such that we can
* easily customize on a per-project basis and attain native support for aliases in; e.g., dev-only scripts.
*
* Regarding precedence of userland aliases. Node’s algorithm gives longer pattern matching keys higher precedence.
* However, key length is actually determined by where the `*` appears in each pattern. Please consult Node’s resolution
* algorithm. What is very important is that while pattern declaration order doesn’t actually matter to Node; i.e.,
* given what was just stated about the way Node determines precedence — it **does** matter to our build tools.
*
* - IMPORTANT: Always declare subpath imports in the descending order of their precedence in Node. This way Vite, Rollup,
* esBuild, and possibly other build tools or plugins can iterate these patterns using a first-to-match strategy.
*/
export default {
asGlobs: {
...userlandAliasesAsGlobs, // In descending order of their precedence in Node.

'react': path.resolve(projDir, './node_modules/preact/compat'),
'react/jsx-runtime': path.resolve(projDir, './node_modules/preact/jsx-runtime'),

'react-dom': path.resolve(projDir, './node_modules/preact/compat'),
'react-dom/test-utils': path.resolve(projDir, './node_modules/preact/test-utils'),
},
asRegExpStrings: {
...userlandAliasesAsRegExpStrings, // In descending order of their precedence in Node.

'^react$': path.resolve(projDir, './node_modules/preact/compat'),
'^react/jsx-runtime$': path.resolve(projDir, './node_modules/preact/jsx-runtime'),

'^react-dom$': path.resolve(projDir, './node_modules/preact/compat'),
'^react-dom/test-utils$': path.resolve(projDir, './node_modules/preact/test-utils'),
},
asFindReplaceRegExps: [
...userlandAliasesAsFindReplaceRegExps, // In descending order of their precedence in Node.

{ find: /^react$/u, replacement: path.resolve(projDir, './node_modules/preact/compat') },
{ find: /^react\/jsx-runtime$/u, replacement: path.resolve(projDir, './node_modules/preact/jsx-runtime') },

Expand Down
3 changes: 3 additions & 0 deletions dev/.files/bin/includes/utilities.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ export default class u {
if (!$is.plainObject(updates)) {
throw new Error('u.updatePkg: Unable to parse `' + updatesFile + '`.');
}
if (await u.isPkgFork()) {
if (updates.$ꓺdefaults?.imports) updates.$ꓺdefaults.imports = {};
}
if (Object.hasOwn(updates.$ꓺset?.engines || {}, 'node')) {
updates.$ꓺset.engines.node = []; // Initialize.
if (nodeVersion.previous) updates.$ꓺset.engines.node.push(nodeVersion.previous);
Expand Down
6 changes: 5 additions & 1 deletion dev/.files/bin/updater/data/_package.json/updates.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@

"type": "module",
"bin": {},
"imports": {},
"imports": {
"#^*": "./*",
"#@*": "./src/resources/*",
"#*": "./src/*"
},
"exports": null,
"sideEffects": [],
"module": "",
Expand Down
10 changes: 10 additions & 0 deletions dev/.files/bin/updater/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ export default async ({ projDir }) => {
*/
const isPkgName = async (name) => name === pkgName; // True if is current package name.

/**
* Tests `pkgName` to see if it’s a fork.
*
* @returns {boolean} True if current package is a fork.
*/
const isPkgFork = async () => pkgName.endsWith('.fork'); // True if current package is a fork.

/**
* Checks dotfile locks.
*
Expand Down Expand Up @@ -215,6 +222,9 @@ export default async ({ projDir }) => {
if (!$is.plainObject(updates)) {
throw new Error('updater: Unable to parse `' + updatesFile + '`.');
}
if (await isPkgFork()) {
if (updates.$ꓺdefaults?.imports) updates.$ꓺdefaults.imports = {};
}
if ('./package.json' === relPath) {
if (Object.hasOwn(updates.$ꓺset?.engines || {}, 'node')) {
updates.$ꓺset.engines.node = []; // Initialize.
Expand Down
10 changes: 10 additions & 0 deletions dev/.files/eslint/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,16 @@ export default async () => {
'ts-ignore': 'allow-with-description',
},
],
'@typescript-eslint/ban-types': [
'warn',
{
'extendDefaults': true,
// We want to use `{}` instead of `object` in some cases.
// e.g., `$preact.Props<{}>` is cleaner than `$preact.Props<object>`.
// {@see https://o5p.me/LDY2YY} {@see https://o5p.me/Cl4qSW}.
'types': { '{}': false },
},
],
'@typescript-eslint/triple-slash-reference': [
'warn',
{
Expand Down
Loading

0 comments on commit fadc61c

Please sign in to comment.