Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry picks #783

Merged
merged 5 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ Available presets

| Name | Version | Description |
| ----------------------- | ------- | ------------------------------------------ |
| [@gasket/preset-api] | 6.46.8 | Create Express-based API with Gasket |
| [@gasket/preset-nextjs] | 6.46.8 | Basic NextJS Framework |
| [@gasket/preset-api] | 6.47.0 | Create Express-based API with Gasket |
| [@gasket/preset-nextjs] | 6.47.0 | Basic NextJS Framework |
| [@gasket/preset-pwa] | 6.46.8 | Turn Gasket apps into Progressive Web Apps |

## Plugins
Expand All @@ -156,6 +156,7 @@ Available plugins

| Name | Version | Description |
| ------------------------------- | ------- | -------------------------------------------------------------------------- |
<<<<<<< HEAD
mmason2-godaddy marked this conversation as resolved.
Show resolved Hide resolved
| [@gasket/plugin-analyze] | 6.46.7 | Gasket Analyzer Plugin |
| [@gasket/plugin-command] | 6.46.2 | Plugin to enable other plugins to inject new gasket commands |
| [@gasket/plugin-config] | 6.46.2 | Supports application-specific (non-Gasket) configuration |
Expand Down Expand Up @@ -185,12 +186,46 @@ Available plugins
| [@gasket/plugin-swagger] | 6.46.7 | Generate and serve swagger docs |
| [@gasket/plugin-webpack] | 6.46.2 | Adds webpack support to your application |
| [@gasket/plugin-workbox] | 6.46.2 | Gasket Workbox Plugin |
=======
mmason2-godaddy marked this conversation as resolved.
Show resolved Hide resolved
| [@gasket/plugin-analyze] | 6.46.8 | Gasket Analyzer Plugin |
| [@gasket/plugin-command] | 6.47.1 | Plugin to enable other plugins to inject new gasket commands |
| [@gasket/plugin-config] | 6.47.0 | Supports application-specific (non-Gasket) configuration |
| [@gasket/plugin-cypress] | 6.46.8 | Integrates Cypress based testing into your Gasket application |
| [@gasket/plugin-docs] | 6.47.1 | Centralize doc files from plugins and modules |
| [@gasket/plugin-docs-graphs] | 6.46.8 | Generate mermaid graphs of an applications gasket lifecycles |
| [@gasket/plugin-docsify] | 6.46.8 | View collated docs with Docsify |
| [@gasket/plugin-docusaurus] | 6.47.0 | Gasket plugin for docusaurus |
| [@gasket/plugin-elastic-apm] | 6.47.0 | Adds Elastic APM instrumentation to your application |
| [@gasket/plugin-express] | 6.46.8 | Adds express support to your application |
| [@gasket/plugin-fastify] | 6.47.0 | Adds fastify support to your application |
| [@gasket/plugin-git] | 6.47.0 | Adds git support to your application |
| [@gasket/plugin-happyfeet] | 6.46.8 | A gasket plugin to enable happyfeet healthchecks |
| [@gasket/plugin-https] | 6.46.8 | Create http/s servers with graceful termination |
| [@gasket/plugin-intl] | 6.47.0 | NodeJS script to build localization files. |
| [@gasket/plugin-jest] | 6.46.8 | Integrated jest into your application. |
| [@gasket/plugin-lifecycle] | 6.46.8 | Allows a gasket/ directory to be used for lifecycle hooks in applications. |
| [@gasket/plugin-lint] | 6.47.0 | Adds GoDaddy standard linting to your application |
| [@gasket/plugin-log] | 6.46.8 | Gasket log plugin |
| [@gasket/plugin-manifest] | 6.46.8 | The web app manifest for progressive Gasket applications |
| [@gasket/plugin-metadata] | 6.47.1 | Adds metadata to gasket lifecycles |
| [@gasket/plugin-metrics] | 6.46.8 | Collect metrics for gasket commands |
| [@gasket/plugin-mocha] | 6.46.8 | Integrates mocha based testing in to your Gasket application |
| [@gasket/plugin-morgan] | 6.46.8 | Adds morgan request logger to your app |
| [@gasket/plugin-nextjs] | 6.47.0 | Adds Next support to your application |
| [@gasket/plugin-redux] | 6.46.8 | Gasket Redux Setup |
| [@gasket/plugin-service-worker] | 6.46.8 | Gasket Service Worker Plugin |
| [@gasket/plugin-start] | 6.46.8 | Adds commands for building and starting Gasket apps |
| [@gasket/plugin-swagger] | 6.46.8 | Generate and serve swagger docs |
| [@gasket/plugin-webpack] | 6.46.8 | Adds webpack support to your application |
| [@gasket/plugin-workbox] | 6.46.8 | Gasket Workbox Plugin |
>>>>>>> 6d4c70e3 (disable prepack doc scripts)
| plugins/site-docs-plugin.js | | |

## Modules

Supporting modules

<<<<<<< HEAD
| Name | Version | Description |
| ----------------------------------------------------------- | ------- | ------------------------------------------------------------------------------------ |
| [@gasket/assets] | 6.45.2 | Gasket assets |
Expand All @@ -208,6 +243,24 @@ Supporting modules
| /Users/agerard/dev/ghec/godaddy/gasket/packages/gasket-core | | |
| /Users/agerard/dev/ghec/godaddy/gasket/packages/iso-test | | |
| [create-gasket-app] | 6.46.7 | starter pack for creating a gasket app |
=======
mmason2-godaddy marked this conversation as resolved.
Show resolved Hide resolved
| Name | Version | Description |
| -------------------------- | ------- | ------------------------------------------------------------------------------------ |
| [@gasket/assets] | 6.46.8 | Gasket assets |
| [@gasket/cli] | 6.47.0 | CLI for rapid application development with gasket |
| [@gasket/data] | 6.47.0 | Helper package for accessing embedded Gasket Data in the browser |
| [@gasket/engine] | 6.46.8 | Plugin engine for gasket |
| [@gasket/fetch] | 6.46.8 | Gasket Fetch API |
| [@gasket/helper-intl] | 6.47.1 | Internal helpers used by loaders to resolve locale file paths |
| [@gasket/log] | 6.46.8 | Gasket client and server logger |
| [@gasket/nextjs] | 6.47.0 | Gasket integrations for Next.js apps |
| [@gasket/react-intl] | 6.47.0 | React component library to enable localization for gasket apps. |
| [@gasket/redux] | 6.46.8 | Gasket Redux Configuration |
| [@gasket/resolve] | 6.47.1 | Essential module resolution & configuration management for gasket plugins & presets. |
| [@gasket/typescript-tests] | 6.47.0 | Not a published package; hosts unit tests to verify TypeScript support |
| [@gasket/utils] | 6.47.1 | Reusable utilities for Gasket internals |
| [create-gasket-app] | 6.47.0 | starter pack for creating a gasket app |
>>>>>>> 6d4c70e3 (disable prepack doc scripts)

## Configurations

Expand Down
8 changes: 7 additions & 1 deletion docs/generated-docs/lifecycle-graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gasket/cli --> create;
init -- exec --> createLogger;
start -- execWaterfall --> createServers;
docsSetup -- exec --> docsGenerate;
docs-cmd(docs) --> docsSetup;
docs-cmd(docs) -- execApply --> docsSetup;
docsSetup -- exec --> docsView;
createServers -- exec --> errorMiddleware;
createServers -- exec --> errorMiddleware;
Expand Down Expand Up @@ -39,10 +39,16 @@ start -- exec --> servers;
express -- exec --> serviceWorkerCacheKey;
preboot -- exec --> start;
start -- execWaterfall --> terminus;
<<<<<<< HEAD
mmason2-godaddy marked this conversation as resolved.
Show resolved Hide resolved
initWebpack -- execSync --> webpack["webpack (deprecated)"];
initWebpack -- execSync --> webpackChain["webpackChain (deprecated)"];
initWebpack -- execWaterfallSync --> webpackConfig;
createLogger -- exec --> winstonTransports;
=======
mmason2-godaddy marked this conversation as resolved.
Show resolved Hide resolved
initWebpack -- execApplySync --> webpack["webpack (deprecated)"];
initWebpack -- execApplySync --> webpackChain["webpackChain (deprecated)"];
initWebpack -- execApplySync --> webpackConfig;
>>>>>>> 6d4c70e3 (disable prepack doc scripts)
composeServiceWorker -- exec --> workbox;
style docs-cmd fill: red;
style *-cmd fill: red;
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/gasket-helper-intl/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"posttest": "npm run lint && npm run typecheck",
"prepack:skip": "npm run docs",
"docs": "jsdoc2md --plugin @godaddy/dmd --files lib/index.js > docs/api.md",
"disabled_prepack": "npm run docs",
"disabled_docs": "jsdoc2md --plugin @godaddy/dmd --files lib/index.js > docs/api.md",
"typecheck": "tsc",
"typecheck:watch": "tsc --watch"
},
Expand Down
11 changes: 5 additions & 6 deletions packages/gasket-plugin-command/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
"lint": "eslint .",
"lint:fix": "npm run lint -- --fix",
"test": "cross-env NODE_OPTIONS='--unhandled-rejections=strict --experimental-vm-modules' jest",
"test:watch": "npm run test --watch",
"test:coverage": "npm run test --coverage",
"posttest": "npm run lint && npm run typecheck",
"prepublish": "npm run build",
"typecheck": "tsc",
"typecheck:watch": "tsc --watch"
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"posttest": "npm run lint",
"disabled_prepack": "npm run docs",
"disabled_docs": "jsdoc2md --plugin @godaddy/dmd --files lib/*.js > docs/api.md"
},
"exports": {
".": {
Expand Down
4 changes: 2 additions & 2 deletions packages/gasket-plugin-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"posttest": "npm run lint && npm run typecheck",
"prepack:skip": "npm run docs",
"docs": "jsdoc2md --plugin @godaddy/dmd --files lib/*.js > docs/api.md",
"disabled_prepack": "npm run docs",
"disabled_docs": "jsdoc2md --plugin @godaddy/dmd --files lib/*.js > docs/api.md",
"typecheck": "tsc",
"typecheck:watch": "tsc --watch"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/gasket-plugin-metadata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"test:watch": "jest --watch",
"test:coverage": "jest --coverage",
"posttest": "npm run lint",
"prepack:skip": "npm run docs",
"docs": "jsdoc2md --plugin @godaddy/dmd --files lib/*.js > docs/api.md"
"disabled_prepack": "npm run docs",
"disabled_docs": "jsdoc2md --plugin @godaddy/dmd --files lib/*.js > docs/api.md"
},
"repository": {
"type": "git",
Expand Down
5 changes: 5 additions & 0 deletions packages/gasket-react-intl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# `@gasket/react-intl`

### 6.47.1

- Accept an array as localesPath in useLocaleRequired, withLocaleRequired, and LocaleRequired ([#779])

### 6.46.3

- Move next-specific utility function to avoid inclusion for browser bundles ([#696])
Expand Down Expand Up @@ -196,3 +200,4 @@
[#523]: https://github.com/godaddy/gasket/pull/523
[#670]: https://github.com/godaddy/gasket/pull/670
[#696]: https://github.com/godaddy/gasket/pull/696
[#779]: https://github.com/godaddy/gasket/pull/779
12 changes: 6 additions & 6 deletions packages/gasket-react-intl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ wrapped component will be rendered.

**Props**

- `localesPath` - (string|function) Path to endpoint with JSON files or
[thunk] that returns one. See more about [locales path] in the plugin docs.
- `localesPath` - (string|function|Array(string|function)) Path to endpoint with JSON files or
[thunk] that returns one. Also supports an array of either. See more about [locales path] in the plugin docs.
- `[options]` - (object) Optional configuration
- `loading` - (string|node) Content to render while loading, otherwise null.
- `initialProps` - (boolean) Enable `getInitialProps` to load locale files
Expand Down Expand Up @@ -99,8 +99,8 @@ content until a [split locales] file loads.

**Props**

- `localesPath` - (string|function) Path to endpoint with JSON files or
[thunk] that returns one. See more about [locales path] in the plugin docs.
- `localesPath` - (string|function|Array(string|function)) Path to endpoint with JSON files or
[thunk] that returns one. Also supports an array of either. See more about [locales path] in the plugin docs.
- `loading` - (string|node) Content to render while loading, otherwise null.

```jsx
Expand Down Expand Up @@ -134,8 +134,8 @@ hook will return the current loading status of the locale file.

**Props**

- `localesPath` - (string|function) Path to endpoint with JSON files or
[thunk] that returns one. See more about [locales path] in the plugin docs.
- `localesPath` - (string|function|Array(string|function)) Path to endpoint with JSON files or
[thunk] that returns one. Also supports an array of either. See more about [locales path] in the plugin docs.

```jsx
import { useLocaleRequired, LocaleStatus } from '@gasket/react-intl';
Expand Down
8 changes: 4 additions & 4 deletions packages/gasket-react-intl/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export type LocaleRequiredWrapper = (props: {
*/
export function withLocaleRequired<Props>(
/** Path containing locale files */
localePathPart?: LocalePathPartOrThunk,
localePathPart?: LocalePathPartOrThunk | LocalePathPartOrThunk[],
options?: {
/** Custom component to show while loading */
loading?: React.ReactNode;
Expand All @@ -50,7 +50,7 @@ export function withLocaleRequired<Props>(

export interface LocaleRequiredProps {
/** Path containing locale files */
localesPath: LocalePathPartOrThunk;
localesPath: LocalePathPartOrThunk | LocalePathPartOrThunk[];
/** Custom component to show while loading */
loading?: React.ReactNode;
}
Expand All @@ -67,7 +67,7 @@ export function LocaleRequired(
*/
export function useLocaleRequired(
/** Path containing locale files */
localePathPart: LocalePathPartOrThunk
localePathPart: LocalePathPartOrThunk | LocalePathPartOrThunk[]
): LocaleStatus;

interface NextStaticContext extends Record<string, any> {
Expand Down Expand Up @@ -152,7 +152,7 @@ export function attachGetInitialProps(
};
},
/** Path containing locale files */
localePathPart: LocalePathPartOrThunk
localePathPart: LocalePathPartOrThunk | LocalePathPartOrThunk[],
): void;

export async function attachedGetInitialProps(
Expand Down
100 changes: 55 additions & 45 deletions packages/gasket-react-intl/src/use-locale-required.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,53 +8,63 @@ import { GasketIntlContext } from './context';
* React that fetches a locale file and returns loading status
* @type {import('./index').useLocaleRequired}
*/
export default function useLocaleRequired(localePathPart) {
export default function useLocaleRequired(localePathParam) {
const { locale, status = {}, dispatch } = useContext(GasketIntlContext);

// thunks are supported but with context will be browser-only (empty object)
const localePath = localeUtils.getLocalePath(localePathPart, locale);

const fileStatus = status[localePath];
if (fileStatus) return fileStatus;

// We cannot use dispatch from useReducer during SSR, so exit early.
// If you want a locale file to be ready, preload it to gasketIntl data
// or load with getStaticProps or getServerSideProps.
if (!isBrowser) return LocaleStatus.LOADING;

// Mutating status state to avoids an unnecessary render with using dispatch.
status[localePath] = LocaleStatus.LOADING;

const url = localeUtils.pathToUrl(localePath);

// Upon fetching, we will dispatch file status and messages to kick off a render.
fetch(url)
.then((r) =>
r.ok
? r.json()
: Promise.reject(
new Error(`Error loading locale file (${r.status}): ${url}`)
)
)
.then((messages) => {
dispatch({
type: LocaleStatus.LOADED,
payload: {
locale,
messages,
file: localePath
}
});
})
.catch((e) => {
console.error(e.message || e); // eslint-disable-line no-console
dispatch({
type: LocaleStatus.ERROR,
payload: {
file: localePath
}
if (!Array.isArray(localePathParam)) {
localePathParam = [localePathParam];
}

const loadingStatuses = localePathParam.map((localePathPart) => {
// thunks are supported but with context will be browser-only (empty object)
const localePath = localeUtils.getLocalePath(localePathPart, locale);

const fileStatus = status[localePath];
if (fileStatus) return fileStatus;

// We cannot use dispatch from useReducer during SSR, so exit early.
// If you want a locale file to be ready, preload it to gasketIntl data
// or load with getStaticProps or getServerSideProps.
if (!isBrowser) return LocaleStatus.LOADING;

// Mutating status state to avoids an unnecessary render with using dispatch.
status[localePath] = LocaleStatus.LOADING;

const url = localeUtils.pathToUrl(localePath);

// Upon fetching, we will dispatch file status and messages to kick off a render.
fetch(url)
.then((r) =>
r.ok
? r.json()
: Promise.reject(
new Error(`Error loading locale file (${r.status}): ${url}`)
)
)
.then((messages) => {
dispatch({
type: LocaleStatus.LOADED,
payload: {
locale,
messages,
file: localePath
}
});
})
.catch((e) => {
console.error(e.message || e); // eslint-disable-line no-console
dispatch({
type: LocaleStatus.ERROR,
payload: {
file: localePath
}
});
});
});

return LocaleStatus.LOADING;
return LocaleStatus.LOADING;
});

if (loadingStatuses.includes(LocaleStatus.ERROR)) return LocaleStatus.ERROR;
if (loadingStatuses.includes(LocaleStatus.LOADING)) return LocaleStatus.LOADING;
return LocaleStatus.LOADED;
}
Loading
Loading