diff --git a/.github/actions/run-build/action.yml b/.github/actions/run-build/action.yml index 807e68db66..6cbfe105fc 100644 --- a/.github/actions/run-build/action.yml +++ b/.github/actions/run-build/action.yml @@ -14,4 +14,4 @@ runs: - if: ${{ steps.yarn-build-cache.outputs.cache-hit != 'true' }} name: 📥 Run build shell: bash - run: yarn nx run-many --target=build --nx-ignore-cycles --skip-nx-cache + run: yarn nx run-many --targets build --nx-ignore-cycles --skip-nx-cache diff --git a/.gitignore b/.gitignore index a5433664c7..ee2fc63849 100644 --- a/.gitignore +++ b/.gitignore @@ -157,6 +157,7 @@ tests/cli/.env ############################ examples/**/types/generated .nx/cache +.nx/workspace-data # Ignore yarn.lock inside templates templates/yarn.lock diff --git a/.nxignore b/.nxignore index 0f0096f154..78adcbc67d 100644 --- a/.nxignore +++ b/.nxignore @@ -1 +1,7 @@ examples/** +.gitignore +.gitattributes +LICENSE +README.md +.npmignore +dist/ diff --git a/.prettierignore b/.prettierignore index c729f7e663..14540d33ad 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,3 +4,5 @@ dist build .strapi /.nx/cache + +/.nx/workspace-data \ No newline at end of file diff --git a/docs/docs/docs/05-utils/pack-up/00-intro.mdx b/docs/docs/docs/05-utils/pack-up/00-intro.mdx deleted file mode 100644 index d4f7ad5009..0000000000 --- a/docs/docs/docs/05-utils/pack-up/00-intro.mdx +++ /dev/null @@ -1,33 +0,0 @@ ---- -title: Introduction -tags: - - pack-up - - bundling - - packages ---- - -## What is pack-up? - -Pack-Up is primarily a CLI interface to develop & build CJS/ESM interopable (meaning you can import your library in either environment with little effort) -packages. It's built on top of [vite](https://vitejs.dev/), but also utilises [esbuild](https://esbuild.github.io/) for certain parts. It also offers a -node API that can be used to build other tools on top of it. - -It's designed to have as little dependencies as possible making it easier to react to changes in the ecosystem as and when we need too. -The configuration format at present is limited and is expected to grow with real-world requirements. - -## Why do we need it? - -Creating packages that work in both CJS and ESM environments is a pain. This tooling library aims to make it easier for _all_ developers, -if you're creating _any_ new project you should bundle your code and therefore use this tool to initialise / build & check the project. -We use internally to bundle all our libraries. Strapi also has it's own plugin system that realistically benefits from having the code bundled -for both the client and server packages of said plugins. Initially we wanted to keep this inside the `@strapi/strapi` package but realised -soon after that this package was required to be more low level than the former. - -## Further reading - -import DocCardList from '@theme/DocCardList'; -import { useCurrentSidebarCategory } from '@docusaurus/theme-common'; - - item.label !== 'Introduction')} -/> diff --git a/docs/docs/docs/05-utils/pack-up/01-commands/00-overview.mdx b/docs/docs/docs/05-utils/pack-up/01-commands/00-overview.mdx deleted file mode 100644 index 72a0fb063f..0000000000 --- a/docs/docs/docs/05-utils/pack-up/01-commands/00-overview.mdx +++ /dev/null @@ -1,17 +0,0 @@ ---- -title: Overview -tags: - - pack-up - - CLI ---- - -Each command has a `node` api equivalent. This is useful if you want to use `pack-up` in your own scripts. - -## Commands - -import DocCardList from '@theme/DocCardList'; -import { useCurrentSidebarCategory } from '@docusaurus/theme-common'; - - item.label !== 'Overview')} -/> diff --git a/docs/docs/docs/05-utils/pack-up/01-commands/01-init.mdx b/docs/docs/docs/05-utils/pack-up/01-commands/01-init.mdx deleted file mode 100644 index e8d07eaf9e..0000000000 --- a/docs/docs/docs/05-utils/pack-up/01-commands/01-init.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: Init -tags: - - pack-up - - CLI ---- - -## Usage - -```bash -$ npx @strapi/pack-up init my-package -``` - -Creates a new package at the given path, by default uses the inbuilt template sensible options for your package to choose from. - -### Options - -- `--template [path]` – path to a custom template of type `TemplateOrTemplateResolver`. - -## API - -### Usage - -```ts -import { init } from '@strapi/pack-up'; - -init({ - path: 'my-package', -}); -``` - -## Typescript - -```ts -interface InitOptions { - cwd?: string; - debug?: boolean; - path: string; - silent?: boolean; - template?: TemplateOrTemplateResolver | string; -} - -type Init = (options: InitOptions) => Promise; - -type TemplateOrTemplateResolver = Template | TemplateResolver; -``` - -You can see `Template` and `TemplateResolver` in on [Templates](/docs/utils/pack-up/templates#template) diff --git a/docs/docs/docs/05-utils/pack-up/01-commands/02-build.mdx b/docs/docs/docs/05-utils/pack-up/01-commands/02-build.mdx deleted file mode 100644 index 900c33729c..0000000000 --- a/docs/docs/docs/05-utils/pack-up/01-commands/02-build.mdx +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: Build -tags: - - pack-up - - CLI ---- - -## Usage - -```bash -$ yarn pack-up build -``` - -Builds your current package based on the configuration in your `package.json` and `package.config.ts` (if applicable). - -### Options - -- `--minify` – minifies the output (default `false`). -- `--sourcemap` – generates sourcemaps for the output (default `true`). - -## API - -### Usage - -```ts -import { build } from '@strapi/pack-up'; - -build(); -``` - -## Typescript - -```ts -interface BuildOptions { - configFile: false; - config?: Config; - cwd?: string; - debug?: boolean; - minify?: boolean; - silent?: boolean; - sourcemap?: boolean; -} - -type Build = (options?: BuildOptions) => Promise; -``` diff --git a/docs/docs/docs/05-utils/pack-up/01-commands/03-check.mdx b/docs/docs/docs/05-utils/pack-up/01-commands/03-check.mdx deleted file mode 100644 index 38dc5048b8..0000000000 --- a/docs/docs/docs/05-utils/pack-up/01-commands/03-check.mdx +++ /dev/null @@ -1,37 +0,0 @@ ---- -title: Check -tags: - - pack-up - - CLI ---- - -## Usage - -```bash -$ yarn pack-up check -``` - -Checks your current package to ensure it's interoperable in the real world. In short, validates the files -in your dist have been produced as we expect & then `esbuild` can actually build, using your exported code. - -## API - -### Usage - -```ts -import { check } from '@strapi/pack-up'; - -check(); -``` - -## Typescript - -```ts -interface CheckOptions { - cwd?: string; - debug?: boolean; - silent?: boolean; -} - -type Check = (options?: CheckOptions) => Promise; -``` diff --git a/docs/docs/docs/05-utils/pack-up/01-commands/04-watch.mdx b/docs/docs/docs/05-utils/pack-up/01-commands/04-watch.mdx deleted file mode 100644 index 0f55407075..0000000000 --- a/docs/docs/docs/05-utils/pack-up/01-commands/04-watch.mdx +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: Watch -tags: - - pack-up - - CLI ---- - -## Usage - -```bash -$ yarn pack-up watch -``` - -Watches your current package for changes and rebuilds when necessary. - -## API - -### Usage - -```ts -import { watch } from '@strapi/pack-up'; - -watch(); -``` - -## Typescript - -```ts -interface WatchOptions { - configFile: false; - config?: Config; - cwd?: string; - debug?: boolean; - silent?: boolean; -} - -type Watch = (options?: WatchOptions) => Promise; -``` diff --git a/docs/docs/docs/05-utils/pack-up/01-commands/_category_.json b/docs/docs/docs/05-utils/pack-up/01-commands/_category_.json deleted file mode 100644 index 3275df661f..0000000000 --- a/docs/docs/docs/05-utils/pack-up/01-commands/_category_.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "position": 1, - "label": "Commands", - "collapsible": true, - "collapsed": true -} diff --git a/docs/docs/docs/05-utils/pack-up/02-config.mdx b/docs/docs/docs/05-utils/pack-up/02-config.mdx deleted file mode 100644 index 74ce9abe84..0000000000 --- a/docs/docs/docs/05-utils/pack-up/02-config.mdx +++ /dev/null @@ -1,87 +0,0 @@ ---- -title: Configuration -tags: - - pack-up - - configuration - - configs ---- - -# Configuring pack-up - -By default, `pack-up` is designed to use the `package.json` as a source of truth to bundle your package. -This creates a seemless alignment between the bundling & publishing process. However, if you require more -flexibility, `pack-up` also supports a configuration file – `packup.config.[mtj]s`. - -## Usage - -```ts -// package.config.ts -import { defineConfig } from '@strapi/pack-up'; - -export default defineConfig({ - minify: true, - sourcemap: false, - externals: ['path', 'fs'], -}); -``` - -## Interface - -```ts -interface Config { - /** - * An array of entry points to bundle. This is useful if you want to bundle something that should not - * be exported by the package, e.g. CLI scripts or Node.js workers. - */ - bundles?: ConfigBundle[]; - /** - * The directory to output the bundle to. - */ - dist?: string; - /** - * A list of external dependencies to exclude from the bundle. - * We already collect the dependencies & peerDeps from the package.json. - */ - externals?: string[]; - /** - * Whether to minify the output or not. - */ - minify?: boolean; - /** - * An array of Vite plugins to use when bundling. - */ - plugins?: PluginOption[] | (({ runtime }: { runtime: Runtime }) => PluginOption[]); - /** - * @alpha - * - * @description Instead of creating as few chunks as possible, this mode - * will create separate chunks for all modules using the original module - * names as file names - */ - preserveModules?: boolean; - /** - * Whether to generate sourcemaps for the output or not. - */ - sourcemap?: boolean; - /** - * The transpilation target of the bundle. This is useful if you're bundling many different CLIs or - * Node.js workers and you want them to be transpiled for the node environment. - */ - runtime?: Runtime; - /** - * Path to the tsconfig file to use for the bundle. - */ - tsconfig?: string; -} - -interface ConfigBundle { - source: string; - import?: string; - require?: string; - runtime?: Runtime; - tsconfig?: string; - types?: string; -} - -type Runtime = '*' | 'node' | 'web'; -``` diff --git a/docs/docs/docs/05-utils/pack-up/03-templates.mdx b/docs/docs/docs/05-utils/pack-up/03-templates.mdx deleted file mode 100644 index dfd708075c..0000000000 --- a/docs/docs/docs/05-utils/pack-up/03-templates.mdx +++ /dev/null @@ -1,81 +0,0 @@ ---- -title: Templates -tags: - - pack-up - - generating - - template ---- - -Templates are only used for the `init` api. You can either pass a path to the file containing your template (it's expected to be -a default export) if you're using the CLI. Or alternatively, if you're using the node functions then you can directly pass your template. - -A template can either be an object (defined below) or a function returning said object. The function recieves an initiatialisation context -to be utilised at the discretion of the template author. - -## Interfaces - -### Template - -```ts -interface Template { - /** - * If you're not using a template in a CLI environment, - * it's not recommended to use prompts. Instead, you should - * just return all the files your template needs in from the - * `getFiles` function. - */ - prompts?: Array; - /** - * A dictionary of the files that will be created in the - * new package. The key is the file name and the value is - * the file contents, we prettify the contents before writing - * using a default config if there's not one in the package. - */ - getFiles: (answers?: Array<{ name: string; answer: string }>) => Promise>; -} - -interface TemplateContext { - cwd: string; - logger: Logger; - packagePath: string; -} - -type TemplateResolver = (ctx: TemplateContext) => Promise