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 18, 2023
1 parent a3420c9 commit 7e5bf83
Show file tree
Hide file tree
Showing 18 changed files with 469 additions and 453 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 Dec 15, 2023 8:20 AM UTC.
# Last generated Dec 18, 2023 2:28 AM UTC.

[production]
node >= 20.9.0
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 Dec 15, 2023 8:20 AM UTC.
# Last generated Dec 18, 2023 2:28 AM 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 Dec 15, 2023 8:20 AM UTC.
# Last generated Dec 18, 2023 2:28 AM 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 Dec 15, 2023 8:20 AM UTC.
# Last generated Dec 18, 2023 2:28 AM 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 Dec 15, 2023 8:20 AM UTC.
# Last generated Dec 18, 2023 2:28 AM 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 Dec 15, 2023 8:20 AM UTC.
# Last generated Dec 18, 2023 2:28 AM UTC.

# 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` Dec 15, 2023 8:20 AM UTC.
* Last generated using `./settings.mjs` Dec 18, 2023 2:28 AM UTC.
*/
{
"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 Dec 15, 2023 8:20 AM UTC.
# Last generated Dec 18, 2023 2:28 AM UTC.

# Locals

Expand Down
10 changes: 6 additions & 4 deletions dev-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
*/
declare const $$__APP_PKG_NAME__$$: string;
declare const $$__APP_PKG_VERSION__$$: string;
declare const $$__APP_PKG_REPOSITORY__$$: string;
declare const $$__APP_PKG_HOMEPAGE__$$: string;
declare const $$__APP_PKG_BUGS__$$: string;

declare const $$__APP_BUILD_TIME_YMD__$$: string;
declare const $$__APP_BUILD_TIME_SQL__$$: string;
declare const $$__APP_BUILD_TIME_ISO__$$: string;
declare const $$__APP_BUILD_TIME_STAMP__$$: string;

declare const $$__APP_BASE_URL__$$: string;
declare const $$__APP_BASE_URL_RESOLVED_NTS__$$: string;
declare const $$__APP_BUILD_TIME_YMD__$$: string;

/**
* Declares prefresh API in Vite plugin.
Expand Down
4 changes: 2 additions & 2 deletions dev/.files/madrun/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default async () => {
* Wrangler commands.
*/
'wrangler': async ({ args }) => {
const settings = wranglerSettings();
const settings = await wranglerSettings();
return {
env: { ...nodeEnvVars, ...cloudflareEnvVars },
opts: { ...('pages' === args._?.[0] ? { cwd: distDir } : {}) },
Expand Down Expand Up @@ -243,7 +243,7 @@ export default async () => {
};
},
'wrangler:flush': async () => {
const settings = wranglerSettings();
const settings = await wranglerSettings();
return {
env: { ...nodeEnvVars, ...cloudflareEnvVars },
cmds: [
Expand Down
11 changes: 2 additions & 9 deletions dev/.files/madrun/includes/events.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,19 @@ export default {

/**
* Attempts to create a remote repository origin at GitHub.
*
* The `--gitignore` argument to `gh repo create` is important because it forces repo creation to also
* create the default branch. Without creating a `.gitignore`, the repo will exist, but it will have no
* branch yet, which is confusing and problematic; i.e., the rest of our automation routines expect a
* default `main` branch to exist, such that we can configure branch protection, etc.
*/
if ('clevercanyon' === repoOwner) {
if (process.env.GH_TOKEN && 'owner' === (await u.gistGetC10NUser()).github?.role) {
u.log($chalk.green('Creating remote project repo at GitHub [' + (args.public ? 'public' : 'private') + '].'));
await u.spawn('gh', ['repo', 'create', repoOwner + '/' + repoName, args.public ? '--public' : '--private', '--gitignore', 'Yeoman']);
await u.spawn('git', ['remote', 'add', 'origin', 'https://github.com/' + $url.encode(repoOwner) + '/' + $url.encode(repoName) + '.git']);
await u.spawn('gh', ['repo', 'create', repoOwner + '/' + repoName, '--source', projDir, args.public ? '--public' : '--private']);
} else {
u.log($chalk.green('Configuring a remote repo origin.'));
await u.spawn('git', ['remote', 'add', 'origin', 'https://github.com/' + $url.encode(repoOwner) + '/' + $url.encode(repoName) + '.git']);
}
} else if (process.env.USER_GITHUB_USERNAME === repoOwner) {
if (process.env.GH_TOKEN) {
u.log($chalk.green('Creating remote project repo at GitHub [' + (args.public ? 'public' : 'private') + '].'));
await u.spawn('gh', ['repo', 'create', repoOwner + '/' + repoName, args.public ? '--public' : '--private', '--gitignore', 'Yeoman']);
await u.spawn('git', ['remote', 'add', 'origin', 'https://github.com/' + $url.encode(repoOwner) + '/' + $url.encode(repoName) + '.git']);
await u.spawn('gh', ['repo', 'create', repoOwner + '/' + repoName, '--source', projDir, args.public ? '--public' : '--private']);
} else {
u.log($chalk.green('Configuring a remote repo origin.'));
await u.spawn('git', ['remote', 'add', 'origin', 'https://github.com/' + $url.encode(repoOwner) + '/' + $url.encode(repoName) + '.git']);
Expand Down
2 changes: 1 addition & 1 deletion dev/.files/postcss/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default async () => {

// Variable compression plugin. I have a request in for variable consolidation also.
// {@see https://github.com/navanshu/postcss-variable-compress/issues/45}.
(await import('postcss-variable-compress')).default(),
(await import('postcss-variable-compress')).default([(name) => name.startsWith('--skip-')]),
],
};
};
23 changes: 14 additions & 9 deletions dev/.files/vite/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ import viteVitestConfig from './includes/vitest/config.mjs';
* @returns Vite configuration object properties.
*/
export default async ({ mode, command, isSsrBuild: isSSRBuild }) => {
/**
* Acquires current time.
*/
const time = $time.now();

/**
* Configures `NODE_ENV` environment variable.
*/
Expand Down Expand Up @@ -85,9 +90,7 @@ export default async ({ mode, command, isSsrBuild: isSSRBuild }) => {
*/
let appEnvPrefixes = ['APP_']; // Added to all builds.
if (isSSRBuild) appEnvPrefixes.push('SSR_APP_'); // Added to SSR builds.

const env = loadEnv(mode, envsDir, appEnvPrefixes); // Includes `APP_IS_VITE`.
env.APP_PKG_NAME = pkg.name; // Adds package name just like app initializers do.
const env = loadEnv(mode, envsDir, appEnvPrefixes); // Includes `APP_IS_VITE` from above.

const appBaseURL = env.APP_BASE_URL || '';
// A trailing slash or no trailing slash — it does matter!
Expand All @@ -107,12 +110,14 @@ export default async ({ mode, command, isSsrBuild: isSSRBuild }) => {
const staticDefs = {
['$$__' + appEnvPrefixes[0] + 'PKG_NAME__$$']: pkg.name || '',
['$$__' + appEnvPrefixes[0] + 'PKG_VERSION__$$']: pkg.version || '',
['$$__' + appEnvPrefixes[0] + 'PKG_REPOSITORY__$$']: pkg.repository || '',
['$$__' + appEnvPrefixes[0] + 'PKG_HOMEPAGE__$$']: pkg.homepage || '',
['$$__' + appEnvPrefixes[0] + 'PKG_BUGS__$$']: pkg.bugs || '',
['$$__' + appEnvPrefixes[0] + 'BASE_URL__$$']: appBaseURL || '',
['$$__' + appEnvPrefixes[0] + 'BASE_URL_RESOLVED_NTS__$$']: appBaseURLResolvedNTS || '',
['$$__' + appEnvPrefixes[0] + 'BUILD_TIME_YMD__$$']: $time.now().toYMD() || '',

['$$__' + appEnvPrefixes[0] + 'BUILD_TIME_YMD__$$']: time.toYMD(),
['$$__' + appEnvPrefixes[0] + 'BUILD_TIME_SQL__$$']: time.toSQL(),
['$$__' + appEnvPrefixes[0] + 'BUILD_TIME_ISO__$$']: time.toISO(),
['$$__' + appEnvPrefixes[0] + 'BUILD_TIME_STAMP__$$']: time.unix().toString(),

['$$__' + appEnvPrefixes[0] + 'BASE_URL__$$']: appBaseURL,
['$$__' + appEnvPrefixes[0] + 'BASE_URL_RESOLVED_NTS__$$']: appBaseURLResolvedNTS,
};
Object.keys(env) // Add string env vars to static defines.
.filter((key) => new RegExp('^(?:' + appEnvPrefixes.map((v) => $str.escRegExp(v)).join('|') + ')', 'u').test(key))
Expand Down
26 changes: 17 additions & 9 deletions dev/.files/vite/includes/c10n/post-processing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export default async ({ mode, wranglerMode, inProdLikeMode, command, isSSRBuild,
*/
if (!isSSRBuild && 'build' === command && ['spa', 'mpa'].includes(appType) && ['cfp'].includes(targetEnv)) {
const isC10n = env.APP_IS_C10N || false,
brand = await u.brand({ mode, baseURL: appBaseURL });
baseURL = appBaseURL, // Shorter alternative.
brand = await u.brand({ mode, baseURL });

for (const file of await $glob.promise(
[
Expand Down Expand Up @@ -176,43 +177,50 @@ export default async ({ mode, wranglerMode, inProdLikeMode, command, isSSRBuild,
fileContents = fileContents.replace(new RegExp($str.escRegExp(key), 'gu'), staticDefs[key]);
}
if (['.well-known/gpc.json'].includes(fileRelPath)) {
const cfpDefaultWellKnownGPC = $cfpꓺhttp.prepareDefaultWellKnownGPC({ appType, brand, isC10n });
const cfpDefaultWellKnownGPC = $cfpꓺhttp.prepareDefaultWellKnownGPC({ appType, baseURL, brand, isC10n });
fileContents = fileContents
.replace('"$$__APP_CFP_DEFAULT_WELL_KNOWN_GPC__$$"', cfpDefaultWellKnownGPC) //
.replace('$$__APP_CFP_DEFAULT_WELL_KNOWN_GPC__$$', cfpDefaultWellKnownGPC);
//
} else if (['.well-known/security.txt'].includes(fileRelPath)) {
const cfpDefaultWellKnownSecurity = $cfpꓺhttp.prepareDefaultWellKnownSecurity({ appType, brand, isC10n });
const cfpDefaultWellKnownSecurity = $cfpꓺhttp.prepareDefaultWellKnownSecurity({ appType, baseURL, brand, isC10n });
fileContents = fileContents.replace('$$__APP_CFP_DEFAULT_WELL_KNOWN_SECURITY__$$', cfpDefaultWellKnownSecurity);
//
} else if (['_headers'].includes(fileRelPath)) {
const cfpDefaultHeaders = $cfpꓺhttp.prepareDefaultHeaders({ appType, brand, isC10n });
const cfpDefaultHeaders = $cfpꓺhttp.prepareDefaultHeaders({ appType, baseURL, brand, isC10n });
fileContents = fileContents.replace('$$__APP_CFP_DEFAULT_HEADERS__$$', cfpDefaultHeaders);
//
} else if (['_redirects'].includes(fileRelPath)) {
const cfpDefaultRedirects = $cfpꓺhttp.prepareDefaultRedirects({ appType, brand, isC10n });
const cfpDefaultRedirects = $cfpꓺhttp.prepareDefaultRedirects({ appType, baseURL, brand, isC10n });
fileContents = fileContents.replace('$$__APP_CFP_DEFAULT_REDIRECTS__$$', cfpDefaultRedirects);
//
} else if (['_routes.json'].includes(fileRelPath)) {
const cfpDefaultRoutes = $cfpꓺhttp.prepareDefaultRoutes({ appType, brand, isC10n });
const cfpDefaultRoutes = $cfpꓺhttp.prepareDefaultRoutes({ appType, baseURL, brand, isC10n });
fileContents = fileContents
.replace('"$$__APP_CFP_DEFAULT_ROUTES__$$"', cfpDefaultRoutes) //
.replace('$$__APP_CFP_DEFAULT_ROUTES__$$', cfpDefaultRoutes);
//
} else if (['manifest.json'].includes(fileRelPath)) {
const cfpDefaultManifest = $cfpꓺhttp.prepareDefaultManifest({ appType, brand, isC10n });
const cfpDefaultManifest = $cfpꓺhttp.prepareDefaultManifest({ appType, baseURL, brand, isC10n });
fileContents = fileContents
.replace('"$$__APP_CFP_DEFAULT_MANIFEST__$$"', cfpDefaultManifest) //
.replace('$$__APP_CFP_DEFAULT_MANIFEST__$$', cfpDefaultManifest);
//
} else if (['ads.txt'].includes(fileRelPath)) {
const cfpDefaultAdsTxt = $cfpꓺhttp.prepareDefaultAdsTxt({ appType, brand, isC10n });
const cfpDefaultAdsTxt = $cfpꓺhttp.prepareDefaultAdsTxt({ appType, baseURL, brand, isC10n });
fileContents = fileContents.replace('$$__APP_CFP_DEFAULT_ADS_TXT__$$', cfpDefaultAdsTxt);
//
} else if (['humans.txt'].includes(fileRelPath)) {
const cfpDefaultHumansTxt = $cfpꓺhttp.prepareDefaultHumansTxt({ appType, brand, isC10n });
const cfpDefaultHumansTxt = $cfpꓺhttp.prepareDefaultHumansTxt({ appType, baseURL, brand, isC10n });
fileContents = fileContents.replace('$$__APP_CFP_DEFAULT_HUMANS_TXT__$$', cfpDefaultHumansTxt);
//
} else if (['robots.txt'].includes(fileRelPath)) {
const cfpDefaultRobotsTxt = $cfpꓺhttp.prepareDefaultRobotsTxt({ appType, baseURL, brand, isC10n, allow: false });
fileContents = fileContents.replace('$$__APP_CFP_DEFAULT_ROBOTS_TXT__$$', cfpDefaultRobotsTxt);

const cfpDefaultAllowRobotsTxt = $cfpꓺhttp.prepareDefaultRobotsTxt({ appType, baseURL, brand, isC10n, allow: true });
fileContents = fileContents.replace('$$__APP_CFP_DEFAULT_ALLOW_ROBOTS_TXT__$$', cfpDefaultAllowRobotsTxt);
//
} else if (['404.html'].includes(fileRelPath)) {
const cfpDefault404 = '<!doctype html>' + $preact.ssr.renderToString($preact.create(StandAlone404));
fileContents = fileContents.replace('$$__APP_CFP_DEFAULT_404_HTML__$$', cfpDefault404);
Expand Down
Loading

0 comments on commit 7e5bf83

Please sign in to comment.