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 Jan 27, 2023
1 parent 6b51212 commit 1c31189
Showing 9 changed files with 211 additions and 143 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Clever Canyon: Utilities
# @clevercanyon/utilities

Clever Canyon’s project development utilities.
7 changes: 7 additions & 0 deletions dev/.files/bin/envs.mjs
Original file line number Diff line number Diff line change
@@ -439,6 +439,13 @@ class Decrypt {
*/
void (async () => {
await yargs(hideBin(process.argv))
.parserConfiguration({
'dot-notation': false,
'strip-aliased': true,
'strip-dashed': true,
'greedy-arrays': true,
'boolean-negation': false,
})
.command({
command: 'install',
describe: 'Installs all envs for dotenv vault.',
4 changes: 2 additions & 2 deletions dev/.files/bin/includes/utilities.mjs
Original file line number Diff line number Diff line change
@@ -933,9 +933,9 @@ export default class u {
}
keys.push(env.USER_DOTENV_KEY_PROD);
}
await u.spawn(path.resolve(binDir, './envs.js'), ['decrypt', '--keys', ...keys]);
await u.spawn(path.resolve(binDir, './envs.mjs'), ['decrypt', '--keys', ...keys]);
} else {
await u.spawn(path.resolve(binDir, './envs.js'), ['install']);
await u.spawn(path.resolve(binDir, './envs.mjs'), ['install']);
}
}

7 changes: 7 additions & 0 deletions dev/.files/bin/install.mjs
Original file line number Diff line number Diff line change
@@ -121,6 +121,13 @@ class Project {
*/
void (async () => {
await yargs(hideBin(process.argv))
.parserConfiguration({
'dot-notation': false,
'strip-aliased': true,
'strip-dashed': true,
'greedy-arrays': true,
'boolean-negation': false,
})
.command({
command: ['project'],
describe: 'Installs NPM packages, envs, and builds distro.',
7 changes: 7 additions & 0 deletions dev/.files/bin/update.mjs
Original file line number Diff line number Diff line change
@@ -443,6 +443,13 @@ class Projects {
*/
void (async () => {
await yargs(hideBin(process.argv))
.parserConfiguration({
'dot-notation': false,
'strip-aliased': true,
'strip-dashed': true,
'greedy-arrays': true,
'boolean-negation': false,
})
.command({
command: ['dotfiles'],
describe: 'Updates project dotfiles.',
83 changes: 65 additions & 18 deletions dev/.files/madrun/config.mjs
Original file line number Diff line number Diff line change
@@ -9,46 +9,93 @@
/* eslint-env es2021, node */

import fs from 'node:fs';
import path from 'node:path';
import fsp from 'node:fs/promises';
import { dirname } from 'desm';
import path from 'node:path';

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

export default {
'envs': async () => ['./dev/.files/bin/envs.mjs {{@}}'],
'envs:push': async () => ['./dev/.files/bin/envs.mjs push {{@}}'],
'envs:pull': async () => ['./dev/.files/bin/envs.mjs pull {{@}}'],
'envs:keys': async () => ['./dev/.files/bin/envs.mjs keys {{@}}'],
'envs:encrypt': async () => ['./dev/.files/bin/envs.mjs encrypt {{@}}'],
'envs:decrypt': async () => ['./dev/.files/bin/envs.mjs decrypt {{@}}'],
'envs:install': async () => ['./dev/.files/bin/envs.mjs install {{@}}'],

'dev': async (args) => ['npx vite dev' + (args.mode ? '' : ' --mode=dev') + ' {{@}}'],
'preview': async (args) => ['npx vite preview' + (args.mode ? '' : ' --mode=dev') + ' {{@}}'],
'build': async (args) => ['npx vite build' + (args.mode ? '' : ' --mode=prod') + ' {{@}}'],
'envs': './dev/.files/bin/envs.mjs {{@}}',
'envs:push': './dev/.files/bin/envs.mjs push {{@}}',
'envs:pull': './dev/.files/bin/envs.mjs pull {{@}}',
'envs:keys': './dev/.files/bin/envs.mjs keys {{@}}',
'envs:encrypt': './dev/.files/bin/envs.mjs encrypt {{@}}',
'envs:decrypt': './dev/.files/bin/envs.mjs decrypt {{@}}',
'envs:install': './dev/.files/bin/envs.mjs install {{@}}',

'dev': async (args) => 'npx vite dev' + (args.mode ? '' : ' --mode=dev') + ' {{@}}',
'preview': async (args) => 'npx vite preview' + (args.mode ? '' : ' --mode=dev') + ' {{@}}',
'build': async (args) => 'npx vite build' + (args.mode ? '' : ' --mode=prod') + ' {{@}}',

'install': async () => {
if (fs.existsSync(path.resolve(projDir, './node_modules'))) {
return ['./dev/.files/bin/install.mjs {{@}}'];
return './dev/.files/bin/install.mjs {{@}}';
}
return ['npm ci', './dev/.files/bin/install.mjs {{@}}'];
},
'install:project': async () => {
if (fs.existsSync(path.resolve(projDir, './node_modules'))) {
return ['./dev/.files/bin/install.mjs project {{@}}'];
return './dev/.files/bin/install.mjs project {{@}}';
}
return ['npm ci', './dev/.files/bin/install.mjs project {{@}}'];
},
'update': async () => ['./dev/.files/bin/update.mjs {{@}}'],
'update:dotfiles': async () => ['./dev/.files/bin/update.mjs dotfiles {{@}}'],
'update': './dev/.files/bin/update.mjs {{@}}',
'update:dotfiles': './dev/.files/bin/update.mjs dotfiles {{@}}',
'update:project': async (args) => {
if (args.h || args.v || args.help || args.version) {
return './dev/.files/bin/update.mjs project {{@}}';
}
return ['./dev/.files/bin/update.mjs dotfiles {{--dryRun}}', './dev/.files/bin/update.mjs project {{@}}'];
},
'update:projects': async () => ['./dev/.files/bin/update.mjs projects {{@}}'],
'update:projects': './dev/.files/bin/update.mjs projects {{@}}',

'wrangler': 'CLOUDFLARE_API_TOKEN="${USER_CLOUDFLARE_TOKEN}" npx wrangler {{@}}',

'on::madrun:default:new': [
'npx @clevercanyon/madrun install:project',
async () => {
let u = './dev/.files/bin/includes/utilities.mjs';
u = (await import(path.resolve(projDir, u))).default;

await fsp.rm(path.resolve(projDir, './.env.me'), { force: true });
await fsp.rm(path.resolve(projDir, './.env.vault'), { force: true });

const projSlug = path.basename(projDir);
await u.updatePkg({
name: '@clevercanyon/' + projSlug,
repository: 'https://github.com/clevercanyon/' + projSlug,
homepage: 'https://github.com/clevercanyon/' + projSlug + '#readme',
bugs: 'https://github.com/clevercanyon/' + projSlug + '/issues',

$unset: /* Reset to defaults. */ [
'private', //
'publishConfig.access',

'version',
'license',
'description',
'funding',
'keywords',

'author',
'contributors',

'config.c10n.&.github.teams',
'config.c10n.&.github.labels',
'config.c10n.&.github.configVersion',
'config.c10n.&.github.envsVersion',

'config.c10n.&.npmjs.teams',
'config.c10n.&.npmjs.configVersions',
],
});
const readmeFile = path.resolve(projDir, './README.md');
let readme = fs.readFileSync(readmeFile).toString(); // Markdown.

'wrangler': async () => ['CLOUDFLARE_API_TOKEN="${USER_CLOUDFLARE_TOKEN}" npx wrangler {{@}}'],
readme = readme.replace(/@clevercanyon\/[^/?#\s]+/gu, '@clevercanyon/' + projSlug);
await fsp.writeFile(readmeFile, readme);
},
],
};
10 changes: 5 additions & 5 deletions dev/.files/vite/config.mjs
Original file line number Diff line number Diff line change
@@ -304,11 +304,11 @@ export default async ({ mode, command /*, ssrBuild */ }) => {
c10n: { pkg, pkgProps },
define: {
// Static replacements.
$$__APP_PKG_NAME__$$: pkg.name || '',
$$__APP_PKG_VERSION__$$: pkg.version || '',
$$__APP_PKG_REPOSITORY__$$: pkg.repository || '',
$$__APP_PKG_HOMEPAGE__$$: pkg.homepage || '',
$$__APP_PKG_BUGS__$$: pkg.bugs || '',
$$__APP_PKG_NAME__$$: JSON.stringify(pkg.name || ''),
$$__APP_PKG_VERSION__$$: JSON.stringify(pkg.version || ''),
$$__APP_PKG_REPOSITORY__$$: JSON.stringify(pkg.repository || ''),
$$__APP_PKG_HOMEPAGE__$$: JSON.stringify(pkg.homepage || ''),
$$__APP_PKG_BUGS__$$: JSON.stringify(pkg.bugs || ''),
},
root: srcDir, // Absolute. Where entry indexes live.
publicDir: path.relative(srcDir, cargoDir), // Relative to `root` directory.
Loading
Oops, something went wrong.

0 comments on commit 1c31189

Please sign in to comment.