Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.5
version: 10.20.0

- name: Setup Node.js environment
uses: actions/setup-node@v4
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
mkdir -p packed-packages
for package in packages/*; do
if [ -d "$package" ]; then
(cd "$package" && npm pack --pack-destination ../../packed-packages)
(cd "$package" && pnpm pack --pack-destination ../../packed-packages)
fi
done

Expand All @@ -87,6 +87,7 @@ jobs:
run: |
cd starter
yarn install
yarn add [email protected]

- name: Build starter
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.5
version: 10.20.0

- name: Setup Node.js environment
uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9.15.5
version: 10.20.0

- name: Setup Node.js environment
uses: actions/setup-node@v4
Expand Down
6 changes: 0 additions & 6 deletions packages/api/jest.int.config.js

This file was deleted.

20 changes: 0 additions & 20 deletions packages/api/jest.unit.config.js

This file was deleted.

1 change: 1 addition & 0 deletions packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"@envelop/validation-cache": "catalog:",
"@graphql-codegen/cli": "catalog:",
"@graphql-codegen/typescript": "catalog:",
"@parcel/watcher": "^2.5.1",
"@types/cookie": "^0.6.0",
"@types/express": "^4.17.16",
"@types/sanitize-html": "^2.9.1",
Expand Down
44 changes: 20 additions & 24 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ USAGE
* [`faststore build [ACCOUNT] [PATH]`](#faststore-build-account-path)
* [`faststore cms-sync [PATH]`](#faststore-cms-sync-path)
* [`faststore create [PATH]`](#faststore-create-path)
* [`faststore dev [ACCOUNT] [PATH] [PORT]`](#faststore-dev-account-path-port)
* [`faststore generate-graphql [PATH]`](#faststore-generate-graphql-path)
* [`faststore dev [PATH] [ACCOUNT] [PORT]`](#faststore-dev-path-account-port)
* [`faststore generate`](#faststore-generate)
* [`faststore help [COMMAND]`](#faststore-help-command)
* [`faststore start [ACCOUNT] [PATH] [PORT]`](#faststore-start-account-path-port)
* [`faststore prepare [PATH]`](#faststore-prepare-path)
* [`faststore serve [ACCOUNT] [PATH] [PORT]`](#faststore-serve-account-path-port)
* [`faststore test [PATH]`](#faststore-test-path)

## `faststore build [ACCOUNT] [PATH]`
Expand All @@ -57,8 +58,8 @@ USAGE
$ faststore build [ACCOUNT] [PATH] [--no-verify]

ARGUMENTS
ACCOUNT The account for which the Discovery is running. Currently noop.
PATH The path where the FastStore being built is. Defaults to cwd.
[ACCOUNT] The account for which the Discovery is running. Currently noop.
[PATH] The path where the FastStore being built is. Defaults to cwd.

FLAGS
--no-verify Skips verification of faststore dependencies version string to prevent usage of packages outside npm
Expand All @@ -74,7 +75,7 @@ USAGE
$ faststore cms-sync [PATH] [-d]

ARGUMENTS
PATH The path where the FastStore being synched with the CMS is. Defaults to cwd.
[PATH] The path where the FastStore being synched with the CMS is. Defaults to cwd.

FLAGS
-d, --dry-run
Expand All @@ -91,7 +92,7 @@ USAGE
$ faststore create [PATH]

ARGUMENTS
PATH The path where the Discovery folder will be created. Defaults to ./discovery.
[PATH] The path where the Discovery folder will be created. Defaults to ./discovery.

DESCRIPTION
Creates a discovery folder based on the starter.store template.
Expand All @@ -106,12 +107,12 @@ _See code: [dist/commands/create.js](https://github.com/vtex/faststore/blob/v3.9

```
USAGE
$ faststore dev [ACCOUNT] [PATH] [PORT] [--watch-plugins]
$ faststore dev [PATH] [ACCOUNT] [PORT] [--watch-plugins]

ARGUMENTS
ACCOUNT The account for which the Discovery is running. Currently noop.
PATH The path where the FastStore being run is. Defaults to cwd.
PORT The port where FastStore should run. Defaults to 3000.
[PATH] The path where the FastStore being run is. Defaults to cwd.
[ACCOUNT] The account for which the Discovery is running. Currently noop.
[PORT] The port where FastStore should run. Defaults to 3000.

FLAGS
--watch-plugins Enable watching for plugin changes
Expand All @@ -123,10 +124,7 @@ _See code: [dist/commands/dev.js](https://github.com/vtex/faststore/blob/v3.95.0

```
USAGE
$ faststore generate-graphql [PATH]

ARGUMENTS
PATH The path where the FastStore GraphQL customization is. Defaults to cwd.
$ faststore generate
```

_See code: [dist/commands/generate-graphql.js](https://github.com/vtex/faststore/blob/v3.95.0/dist/commands/generate-graphql.js)_
Expand All @@ -137,10 +135,10 @@ Display help for faststore.

```
USAGE
$ faststore help [COMMAND] [-n]
$ faststore help [COMMAND...] [-n]

ARGUMENTS
COMMAND Command to show help for.
[COMMAND...] Command to show help for.

FLAGS
-n, --nested-commands Include all nested commands in the output.
Expand All @@ -149,18 +147,16 @@ DESCRIPTION
Display help for faststore.
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.1.22/src/commands/help.ts)_
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.35/src/commands/help.ts)_

## `faststore start [ACCOUNT] [PATH] [PORT]`
## `faststore prepare [PATH]`

```
USAGE
$ faststore start [ACCOUNT] [PATH] [PORT]
$ faststore prepare [PATH]

ARGUMENTS
ACCOUNT The account for which the Discovery is running. Currently noop.
PATH The path where the FastStore being run is. Defaults to cwd.
PORT The port where FastStore should run. Defaults to 3000.
[PATH] The path where the FastStore being run is. Defaults to cwd.
```

_See code: [dist/commands/start.js](https://github.com/vtex/faststore/blob/v3.95.0/dist/commands/start.js)_
Expand All @@ -172,7 +168,7 @@ USAGE
$ faststore test [PATH]

ARGUMENTS
PATH The path where the FastStore being tested is. Defaults to cwd.
[PATH] The path where the FastStore being tested is. Defaults to cwd.
```

_See code: [dist/commands/test.js](https://github.com/vtex/faststore/blob/v3.95.0/dist/commands/test.js)_
Expand Down
17 changes: 0 additions & 17 deletions packages/cli/bin/dev

This file was deleted.

2 changes: 1 addition & 1 deletion packages/cli/bin/dev.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off

node "%~dp0\dev" %*
node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
5 changes: 0 additions & 5 deletions packages/cli/bin/run

This file was deleted.

5 changes: 0 additions & 5 deletions packages/cli/jest.config.cjs

This file was deleted.

28 changes: 15 additions & 13 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
"homepage": "https://github.com/vtex/faststore",
"license": "MIT",
"main": "dist/index.js",
"exports": {
".": "./dist/index.js",
"./runner": "./bin/run.js"
},
"repository": "vtex/faststore",
"files": [
"/bin",
Expand All @@ -33,27 +37,23 @@
"dotenv": "^16.4.5",
"fs-extra": "^11",
"globby": "^15.0.0",
"graphql": "catalog:",
"ora": "5.4.1",
"path": "^0.12.7"
"ora": "5.4.1"
},
"devDependencies": {
"@antfu/ni": "catalog:",
"graphql": "catalog:",
"@graphql-codegen/cli": "catalog:",
"@types/chai": "^4",
"@parcel/watcher": "^2.5.1",
"@types/degit": "^2.8.6",
"@types/fs-extra": "^11",
"@types/jest": "catalog:",
"@types/node": "catalog:",
"chai": "^4",
"jest": "catalog:",
"oclif": "^4",
"shx": "^0.3.3",
"ts-jest": "catalog:",
"ts-node": "^10.9.1",
"tslib": "catalog:",
"tsup": "^8.5.0",
"typescript": "catalog:",
"vite": "catalog:"
"vitest": "catalog:"
},
"oclif": {
"bin": "faststore",
Expand All @@ -70,10 +70,10 @@
]
},
"scripts": {
"build": "tsc -b",
"test": "jest src/**/*.test.ts",
"build": "tsup-node",
"test": "vitest run src/**/*.test.ts",
"postpack": "shx rm -f oclif.manifest.json",
"prepack": "na run && oclif manifest && oclif readme",
"prepack": "na run build && oclif readme",
"version": "oclif readme && git add README.md"
},
"bugs": "https://github.com/vtex/faststore/issues",
Expand All @@ -82,7 +82,9 @@
],
"types": "dist/index.d.ts",
"peerDependencies": {
"@antfu/ni": "catalog:"
"@antfu/ni": "catalog:",
"@parcel/watcher": "^2.5.1",
"graphql": "catalog:"
},
"engines": {
"node": ">=20"
Expand Down
44 changes: 35 additions & 9 deletions packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { Args, Command, Flags } from '@oclif/core'
import chalk from 'chalk'
import { spawnSync } from 'child_process'
import { existsSync } from 'fs'
import { copySync, moveSync, readdirSync, removeSync } from 'fs-extra'
import fsExtra from 'fs-extra'
import { getPreferredPackageManager } from '../utils/commands'
import { checkDeprecatedSecretFiles } from '../utils/deprecations'
import { getBasePath, withBasePath } from '../utils/directory'
import { logger } from '../utils/logger'
import path from 'path'
import { fileURLToPath } from 'url'

const { copySync, moveSync, readdirSync, removeSync } = fsExtra

export default class Build extends Command {
static args = {
Expand Down Expand Up @@ -50,20 +54,40 @@ export default class Build extends Command {

const packageManager = getPreferredPackageManager()

spawnSync(`${packageManager} run generate`, {
const binCli = path.join(
fileURLToPath(
import.meta.resolve('@faststore/cli/runner', import.meta.url)
)
)
let scriptResult = spawnSync(`node ${binCli} generate`, {
shell: true,
cwd: tmpDir,
stdio: 'inherit',
})

const buildResult = spawnSync(`${packageManager} run build`, {
if (scriptResult.error || scriptResult.status !== 0) {
throw 'Error: Cant run generate' + (scriptResult.error?.message ?? '')
}

scriptResult = spawnSync(`node ${binCli} cache-graphql`, {
shell: true,
stdio: 'inherit',
})

if (scriptResult.error || scriptResult.status !== 0) {
throw (
'Error: Unable to run cache-graphql' +
(scriptResult.error?.message ?? '')
)
}

scriptResult = spawnSync(`${packageManager} run build`, {
shell: true,
cwd: tmpDir,
stdio: 'inherit',
})

if (buildResult.status && buildResult.status !== 0) {
process.exit(buildResult.status)
if (scriptResult.status && scriptResult.status !== 0) {
process.exit(scriptResult.status)
}

await normalizeStandaloneBuildDir(basePath)
Expand Down Expand Up @@ -146,9 +170,11 @@ async function checkDeps(basePath: string): Promise<Array<string>> {

try {
const {
devDependencies = {},
dependencies = {},
peerDependencies = {},
default: {
devDependencies = {},
dependencies = {},
peerDependencies = {},
},
} = await import(packageJsonPath)

const allDeps: Record<string, string> = Object.assign(
Expand Down
Loading