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 Oct 10, 2023
1 parent fdbbf97 commit ab70489
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .browserslistrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# Generated data.
# <generated:start>

# Last generated Mon, Oct 9, 2023, 5:45:45 PM EDT.
# Last generated Mon, Oct 9, 2023, 9:57:11 PM EDT.

[production]
last 1 chrome versions
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 Mon, Oct 9, 2023, 5:45:45 PM EDT.
# Last generated Mon, Oct 9, 2023, 9:57:11 PM EDT.

# 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 Mon, Oct 9, 2023, 5:45:45 PM EDT.
# Last generated Mon, Oct 9, 2023, 9:57:10 PM EDT.

# 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 Mon, Oct 9, 2023, 5:45:45 PM EDT.
# Last generated Mon, Oct 9, 2023, 9:57:10 PM EDT.

# 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 Mon, Oct 9, 2023, 5:45:45 PM EDT.
# Last generated Mon, Oct 9, 2023, 9:57:11 PM EDT.

# 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 Mon, Oct 9, 2023, 5:45:45 PM EDT.
# Last generated Mon, Oct 9, 2023, 9:57:11 PM EDT.

# Packages

Expand Down
2 changes: 1 addition & 1 deletion .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` Mon, Oct 9, 2023, 5:45:45 PM EDT.
* Last generated using `./settings.mjs` Mon, Oct 9, 2023, 9:57:10 PM EDT.
*/
{
"editor.formatOnType": false,
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 Mon, Oct 9, 2023, 5:45:45 PM EDT.
# Last generated Mon, Oct 9, 2023, 9:57:11 PM EDT.

# Locals

Expand Down
26 changes: 10 additions & 16 deletions dev/.files/bin/includes/utilities.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const __dirname = $fs.imuDirname(import.meta.url);
const binDir = path.resolve(__dirname, '..');
const projDir = path.resolve(__dirname, '../../../..');

const { pkgFile, pkgName, pkgPrivate, pkgRepository, pkgBuildAppType } = (() => {
const { pkgFile, pkgName, pkgPrivate, pkgBuildAppType } = (() => {
const pkgFile = path.resolve(projDir, './package.json');

if (!fs.existsSync(pkgFile)) {
Expand All @@ -34,10 +34,9 @@ const { pkgFile, pkgName, pkgPrivate, pkgRepository, pkgBuildAppType } = (() =>
}
const pkgName = $obp.get(pkg, 'name', '');
const pkgPrivate = $obp.get(pkg, 'private');
const pkgRepository = $obp.get(pkg, 'repository', '');
const pkgBuildAppType = $obp.get(pkg, 'config.c10n.&.build.appType', '');

return { pkgFile, pkgName, pkgPrivate, pkgRepository, pkgBuildAppType };
return { pkgFile, pkgName, pkgPrivate, pkgBuildAppType };
})();
const Octokit = OctokitCore.plugin(OctokitPluginPaginateRest);
const octokit = new Octokit({ auth: process.env.USER_GITHUB_TOKEN || '' });
Expand Down Expand Up @@ -131,20 +130,15 @@ export default class u {
}

static async isPkgName(name) {
return name === pkgName; // Package with this specific name?
return name === pkgName; // True if is current package name.
}

// @todo Deprecate this in favor of `isPkgName()`.
static async isPkgRepo(ownerRepo) {
return new RegExp('[:/]' + $str.escRegExp(ownerRepo) + '(?:\\.git)?$', 'iu').test(pkgRepository);
static async isPkgFork() {
return pkgName.endsWith('.fork'); // True if current package is a fork.
}

static async isPkgRepoFork() {
return /[:/][^/]+\/[^/]+\.fork(?:\.git)?$/iu.test(pkgRepository);
}

static async isPkgRepoTemplate() {
return /[:/][^/]+\/skeleton(?:\.[^/]+)?(?:\.git)?$/iu.test(pkgRepository);
static async isPkgSkeleton() {
return 'skeleton' === pkgName || pkgName.startsWith('skeleton.');
}

static async pkgIncrementVersion(opts = { dryRun: false }) {
Expand Down Expand Up @@ -200,7 +194,7 @@ export default class u {
if (nodeVersion.npm.forwardCompat.length) updates.$ꓺset.engines.npm = updates.$ꓺset.engines.npm.concat(nodeVersion.npm.forwardCompat);
updates.$ꓺset.engines.npm = (updates.$ꓺset.engines.npm.length ? '^' : '') + updates.$ꓺset.engines.npm.join(' || ^');
}
if (await u.isPkgRepo('clevercanyon/dev-deps')) {
if (await u.isPkgName('@clevercanyon/dev-deps')) {
if (updates.$ꓺdefaults?.['devDependenciesꓺ@clevercanyon/dev-deps']) {
delete updates.$ꓺdefaults['devDependenciesꓺ@clevercanyon/dev-deps'];
}
Expand Down Expand Up @@ -550,7 +544,7 @@ export default class u {
homepage: pkg.homepage || defaultHomepage,
description: pkg.description || defaultDescription,

is_template: await u.isPkgRepoTemplate(),
is_template: await u.isPkgSkeleton(),
});
await octokit.request('PUT /repos/{owner}/{repo}/vulnerability-alerts', { owner, repo });
await octokit.request('PUT /repos/{owner}/{repo}/automated-security-fixes', { owner, repo });
Expand Down Expand Up @@ -1163,7 +1157,7 @@ export default class u {

for (const [dependency] of Object.entries(pkg.dependencies || {})) dependenciesToUpdate.push(dependency);
for (const [dependency] of Object.entries(pkg.peerDependencies || {})) dependenciesToUpdate.push(dependency);
if (!(await u.isPkgRepo('clevercanyon/dev-deps')))
if (!(await u.isPkgName('@clevercanyon/dev-deps')))
for (const [dependency] of Object.entries((await u.depPkg('@clevercanyon/dev-deps'))?.dependencies || {})) {
if (/^@clevercanyon\//iu.test(dependency)) dependenciesToUpdate.push(dependency);
}
Expand Down
6 changes: 3 additions & 3 deletions dev/.files/bin/update.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ class Dotfiles {

let skeletonBranch = 'main';

if (await u.isPkgRepo('clevercanyon/skeleton')) {
if (await u.isPkgName('@clevercanyon/skeleton')) {
if (!(await u.isGitRepo())) {
throw new Error('`clevercanyon/skeleton` is not a git repo.');
}
Expand All @@ -498,14 +498,14 @@ class Dotfiles {
* Saves any pending skeleton changes; else checks state.
*/

if ((await u.isPkgRepo('clevercanyon/skeleton')) && (await u.isGitRepoDirty())) {
if ((await u.isPkgName('@clevercanyon/skeleton')) && (await u.isGitRepoDirty())) {
u.log($chalk.green('Updating `clevercanyon/skeleton` git repo; `' + skeletonBranch + '` branch.'));
u.log(' ' + $chalk.green('i.e., saving latest skeleton changes before self-update.'));

if (!this.args.dryRun) {
await u.gitAddCommitPush((this.args.message + ' [d]').trim());
}
} else if (await u.isPkgRepo('clevercanyon/skeleton')) {
} else if (await u.isPkgName('@clevercanyon/skeleton')) {
// Don't perform a self-update if the remote isn't in sync with our local copy.
if ((await u.gitLocalRepoSHA(projDir, skeletonBranch)) !== (await u.gitRemoteRepoSHA(skeletonRepoURL, skeletonBranch))) {
throw new Error('`clevercanyon/skeleton` is out of sync with git remote origin; `' + skeletonBranch + '` branch.');
Expand Down
20 changes: 9 additions & 11 deletions dev/.files/bin/updater/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import fs from 'node:fs';
import fsp from 'node:fs/promises';
import path from 'node:path';
import { $chalk, $fs, $prettier } from '../../../../node_modules/@clevercanyon/utilities.node/dist/index.js';
import { $is, $json, $obj, $obp, $str } from '../../../../node_modules/@clevercanyon/utilities/dist/index.js';
import { $is, $json, $obj, $obp } from '../../../../node_modules/@clevercanyon/utilities/dist/index.js';
import nodeVersion from '../includes/node-version.mjs';
import customRegExp from './data/custom-regexp.mjs';

Expand Down Expand Up @@ -44,26 +44,24 @@ export default async ({ projDir }) => {
/**
* Gets properties from `./package.json` file.
*/
const { pkgRepository, pkgDotfileLocks } = await (async () => {
const { pkgName, pkgDotfileLocks } = await (async () => {
const pkg = await getPkg();
const pkgRepository = pkg.repository || '';
const pkgName = pkg.name || '';

let pkgDotfileLocks = $obp.get(pkg, 'config.c10n.&.dotfiles.lock', []);
pkgDotfileLocks = pkgDotfileLocks.map((relPath) => path.resolve(projDir, relPath));

return { pkgRepository, pkgDotfileLocks };
return { pkgName, pkgDotfileLocks };
})();

/**
* Tests `pkgRepository` against an `owner/repo` string.
* Tests `pkgName` against current package.
*
* @param {string} ownerRepo An `owner/repo` string.
* @param {string} name A fully qualified package name.
*
* @returns {boolean} True if current package repo is `ownerRepo`.
* @returns {boolean} True if is current package name.
*/
const isPkgRepo = async (ownerRepo) => {
return new RegExp('[:/]' + $str.escRegExp(ownerRepo) + '(?:\\.git)?$', 'iu').test(pkgRepository);
};
const isPkgName = async (name) => name === pkgName; // True if is current package name.

/**
* Checks dotfile locks.
Expand Down Expand Up @@ -233,7 +231,7 @@ export default async ({ projDir }) => {
updates.$ꓺset.engines.npm = (updates.$ꓺset.engines.npm.length ? '^' : '') + updates.$ꓺset.engines.npm.join(' || ^');
}
}
if ('./package.json' === relPath && (await isPkgRepo('clevercanyon/dev-deps'))) {
if ('./package.json' === relPath && (await isPkgName('@clevercanyon/dev-deps'))) {
if (updates.$ꓺdefaults?.['devDependenciesꓺ@clevercanyon/dev-deps']) {
delete updates.$ꓺdefaults['devDependenciesꓺ@clevercanyon/dev-deps'];
}
Expand Down
2 changes: 1 addition & 1 deletion dev/.files/madrun/includes/events.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export default {
.readFile(envProdFile)
.then(async (envProd) => {
envProd = envProd.toString();
envProd = envProd.replace(/^(APP_BASE_URL)\s*=\s*[^\r\n]*$/gmu, "$1='https://" + pkgSlug + '.' + hop.hostname + "'");
envProd = envProd.replace(/^(APP_BASE_URL)\s*=\s*[^\r\n]*$/gmu, "$1='https://" + pkgSlug + '.' + hop.hostname + "/'");
await fsp.writeFile(envProdFile, envProd);
})
.catch((error) => {
Expand Down
2 changes: 1 addition & 1 deletion dev/.files/vite/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export default async ({ mode, command, ssrBuild: isSSRBuild }) => {

root: srcDir, // Absolute path where entry indexes live.
publicDir: isSSRBuild ? false : path.relative(srcDir, cargoDir),
base: (appBaseURL ? $url.parse(appBaseURL).pathname : '') || '/', // @todo Update to `$url.toPath()`.
base: (appBaseURL ? $url.toPath(appBaseURL) : '') || '/',

envDir: path.relative(srcDir, envsDir), // Relative to `root` directory.
envPrefix: appEnvPrefixes, // Env vars w/ these prefixes become part of the app.
Expand Down
10 changes: 5 additions & 5 deletions dev/.files/vscode/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default async () => {
// Plus these additional hidden files we control using ext: `PeterSchmalfeldt.explorer-exclude`.
// These work together with the additional setting below for the extension: `explorerExclude.backup`.

...(!(await u.isPkgRepo('clevercanyon/skeleton'))
...(!(await u.isPkgName('@clevercanyon/skeleton'))
? {
...exclusions.asBoolProps(
exclusions.asRelativeGlobs(
Expand Down Expand Up @@ -155,7 +155,7 @@ export default async () => {
// Plus everything in `../../../.gitignore`.
// ... plus these additional search ignores.

...(!(await u.isPkgRepo('clevercanyon/skeleton'))
...(!(await u.isPkgName('@clevercanyon/skeleton'))
? {
...exclusions.asBoolProps(
exclusions.asRootedRelativeGlobs(
Expand Down Expand Up @@ -204,7 +204,7 @@ export default async () => {
// Comment Anchors uses minimatch, with `{ dot: false }`.
'commentAnchors.workspace.excludeFiles': exclusions.asBracedGlob(
[
...(!(await u.isPkgRepo('clevercanyon/skeleton')) //
...(!(await u.isPkgName('@clevercanyon/skeleton')) //
? [...exclusions.devDotFileIgnores]
: []),
...exclusions.logIgnores,
Expand Down Expand Up @@ -232,7 +232,7 @@ export default async () => {
*
* @see https://github.com/StarlaneStudios/vscode-comment-anchors/issues/209
*/
'commentAnchors.workspace.matchFiles': (await u.isPkgRepo('clevercanyon/skeleton'))
'commentAnchors.workspace.matchFiles': (await u.isPkgName('@clevercanyon/skeleton'))
? '{**/,**/dev/.files/,**/dev/.files/**/}*.' + extensions.asBracedGlob([...extensions.commentAnchorsContent])
: '**/*.' + extensions.asBracedGlob([...extensions.commentAnchorsContent]),

Expand Down Expand Up @@ -301,7 +301,7 @@ export default async () => {
'tailwindCSS.classAttributes': tailwindSettings.classAttributes,
'tailwindCSS.includeLanguages': {}, // Defaults ok; {@see https://o5p.me/kaPo3F}.
'tailwindCSS.files.exclude': [
...(!(await u.isPkgRepo('clevercanyon/skeleton')) ? [...exclusions.devDotFileIgnores] : []),
...(!(await u.isPkgName('@clevercanyon/skeleton')) ? [...exclusions.devDotFileIgnores] : []),
...exclusions.logIgnores, //
...exclusions.backupIgnores,
...exclusions.patchIgnores,
Expand Down
Loading

0 comments on commit ab70489

Please sign in to comment.