Page Not Found
+Looks like you've followed a broken link or entered a URL that doesn't exist on this site.
+ +If this is a brand new site, you can add files to the netlify/publish
directory or configure a custom publish directory.
+
diff --git a/package.json b/package.json index fcb5bfdf2a8..bb33e97350c 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,9 @@ "scripts": { "prepare": "is-ci || husky install node_modules/@netlify/eslint-config-node/.husky/", "start": "node ./bin/run.js", - "build": "tsc", + "build": "run-s build:ts build:post", + "build:ts": "tsc", + "build:post": "node scripts/postbuild.mjs", "dev": "tsc --watch", "test": "run-s format test:dev", "format": "run-s format:check-fix:*", diff --git a/scripts/postbuild.mjs b/scripts/postbuild.mjs new file mode 100644 index 00000000000..bb475584b42 --- /dev/null +++ b/scripts/postbuild.mjs @@ -0,0 +1,10 @@ +import fs from 'fs' +import path from 'path' +import { fileURLToPath } from 'url' + +const cwd = path.dirname(fileURLToPath(import.meta.url)) + +const srcPath = path.resolve(cwd, '../src/lib/templates') +const destPath = path.resolve(cwd, '../dist/lib/templates') + +fs.cpSync(srcPath, destPath, { recursive: true }) diff --git a/src/commands/base-command.ts b/src/commands/base-command.ts index 592f464b755..aac1e0be9b7 100644 --- a/src/commands/base-command.ts +++ b/src/commands/base-command.ts @@ -16,9 +16,10 @@ import inquirer from 'inquirer' // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'inqu... Remove this comment to see the full error message import inquirerAutocompletePrompt from 'inquirer-autocomplete-prompt' import merge from 'lodash/merge.js' -import { NetlifyAPI } from 'netlify' +import { NetlifyAPI, APICache } from 'netlify' import { getAgent } from '../lib/http-agent.js' +import { getPathInHome } from '../lib/settings.js' import { NETLIFY_CYAN, USER_AGENT, @@ -77,6 +78,13 @@ const COMMANDS_WITHOUT_WORKSPACE_OPTIONS = new Set(['api', 'recipes', 'completio */ const COMMANDS_WITH_FEATURE_FLAGS = new Set(['build', 'dev', 'deploy']) +const apiCache = new APICache({ + fsPath: getPathInHome(['api-cache']), + ttl: 30_000, + // swr: 3_600_000, + swr: Infinity, +}) + /** Formats a help list correctly with the correct indent */ const formatHelpList = (textArray: string[]) => textArray.join('\n').replace(/^/gm, ' '.repeat(HELP_INDENT_WIDTH)) @@ -566,7 +574,7 @@ export default class BaseCommand extends Command { httpProxy: flags.httpProxy, certificateFile: flags.httpProxyCertificateFilename, }) - const apiOpts = { ...apiUrlOpts, agent } + const apiOpts = { ...apiUrlOpts, agent, cache: apiCache } // TODO: remove typecast once we have proper types for the API const api = new NetlifyAPI(token || '', apiOpts) as NetlifyOptions['api'] @@ -697,6 +705,7 @@ export default class BaseCommand extends Command { try { return await resolveConfig({ accountId: this.accountId, + apiCache, config: config.configFilePath, packagePath: config.packagePath, repositoryRoot: config.repositoryRoot, diff --git a/src/lib/templates/404.html b/src/lib/templates/404.html new file mode 100644 index 00000000000..6051fee9d07 --- /dev/null +++ b/src/lib/templates/404.html @@ -0,0 +1,103 @@ + +
+ + + +Looks like you've followed a broken link or entered a URL that doesn't exist on this site.
+ +If this is a brand new site, you can add files to the netlify/publish
directory or configure a custom publish directory.
+