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

Improvements #345

Merged
merged 9 commits into from
Dec 13, 2024
4 changes: 2 additions & 2 deletions e2e/shadcn-ui-e2e/tests/shadcn-ui.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ describe('shadcn/ui e2e', () => {
await runNxCommandAsync(`add-component ${uiLibName} button`)

expect(() => checkFilesExist(
`${uiLibName}/src/ui/button.tsx`,
`${uiLibName}/src/button.tsx`,
)).not.toThrow()
})

it('should be able add sidebar ui', async () => {
await runNxCommandAsync(`add-component ${uiLibName} sidebar --overwrite`) // Overwrites are needed because of button ui conflicts

expect(() => checkFilesExist(
`${uiLibName}/src/ui/sidebar.tsx`,
`${uiLibName}/src/sidebar.tsx`,
`${uiLibName}/src/hooks/use-mobile.tsx`,
)).not.toThrow()
})
Expand Down
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
"rxjs-for-await": "^1.0.0",
"shelljs": "^0.8.5",
"tar": "^7.4.3",
"tslib": "^2.8.0",
"tslib": "^2.8.1",
"yargs": "^17.7.2"
},
"devDependencies": {
"@google-cloud/storage": "^7.13.0",
"@jamesives/github-pages-deploy-action": "^4.6.8",
"@google-cloud/storage": "^7.14.0",
"@jamesives/github-pages-deploy-action": "^4.6.9",
"@jscutlery/semver": "^5.3.1",
"@nx/eslint-plugin": "20.0.0",
"@nx/jest": "20.0.0",
Expand All @@ -56,29 +56,29 @@
"@nx/plugin": "20.0.0",
"@nx/react": "20.0.0",
"@nx/webpack": "20.0.0",
"@pulumi/gcp": "^8.6.0",
"@pulumi/pulumi": "^3.137.0",
"@pulumi/gcp": "^8.10.0",
"@pulumi/pulumi": "^3.141.0",
"@types/jest": "29.5.14",
"@types/node": "22.7.9",
"@types/node": "22.9.3",
"@types/shelljs": "^0.8.15",
"@types/yargs": "^17.0.33",
"@typescript-eslint/eslint-plugin": "8.11.0",
"@typescript-eslint/parser": "8.11.0",
"@typescript-eslint/eslint-plugin": "8.15.0",
"@typescript-eslint/parser": "8.15.0",
"@vercel/ncc": "0.34.0",
"dotenv": "16.4.5",
"eslint": "8.57.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"express": "^4.21.1",
"husky": "^9.1.6",
"husky": "^9.1.7",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"nx": "20.0.0",
"prettier": "3.3.3",
"ts-jest": "29.2.5",
"ts-node": "10.9.2",
"tslint": "~6.1.3",
"typescript": "5.6.3"
"typescript": "5.7.2"
},
"packageManager": "[email protected]"
}
9 changes: 6 additions & 3 deletions packages/core/src/utils/exec-package-manager-command.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { detectPackageManager, getPackageManagerCommand } from 'nx/src/utils/package-manager'
import {
detectPackageManager,
getPackageManagerCommand as nxGetPackageManagerCommand
} from 'nx/src/utils/package-manager'

import { buildCommand } from './build-command'
import { execCommand, Options } from './exec'

export function getPackageManagerDlxCommand() {
return getPackageManagerCommand(detectPackageManager()).dlx
return process.env.NX_EXTEND_COMMAND_USE_NPX ? 'npx' : nxGetPackageManagerCommand(detectPackageManager()).dlx
}

export function execPackageManagerCommand(command: string, options?: Options) {
return execCommand(buildCommand([
process.env.NX_EXTEND_COMMAND_USE_NPX ? 'npx' : getPackageManagerDlxCommand(),
getPackageManagerDlxCommand(),
command
]), options)
}
12 changes: 6 additions & 6 deletions packages/docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"license": "MIT",
"main": "src/index.js",
"devDependencies": {
"@docusaurus/core": "3.5.2",
"@docusaurus/module-type-aliases": "3.5.2",
"@docusaurus/preset-classic": "3.5.2",
"@docusaurus/tsconfig": "3.5.2",
"@docusaurus/types": "3.5.2",
"typescript": "~5.6.3"
"@docusaurus/core": "3.6.3",
"@docusaurus/module-type-aliases": "3.6.3",
"@docusaurus/preset-classic": "3.6.3",
"@docusaurus/tsconfig": "3.6.3",
"@docusaurus/types": "3.6.3",
"typescript": "~5.7.2"
},
"peerDependencies": {
"@docusaurus/core": "^3.4.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/gcp-functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
"main": "src/index.js",
"devDependencies": {
"@google-cloud/functions-framework": "^3.4.2",
"@nestjs/common": "^10.4.6",
"@nestjs/core": "^10.4.6",
"@nestjs/platform-express": "^10.4.6"
"@nestjs/common": "^10.4.8",
"@nestjs/core": "^10.4.8",
"@nestjs/platform-express": "^10.4.8"
},
"peerDependencies": {
"@nx/devkit": "^20.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { uploadExecutor } from '../upload.impl'

jest.mock('@nx-extend/core', () => {
const originalModule = jest.requireActual('@nx-extend/core')

//Mock the default export and named export 'foo'
return {
__esModule: true,
...originalModule,
execCommand: jest.fn(() => ({ success: true }))
}
})

import { execCommand as execCommandMock } from '@nx-extend/core'
import { workspaceRoot } from 'nx/src/utils/workspace-root'

describe('Upload', () => {
it('should fail when directories is invalid', () => {
uploadExecutor(
{ bucket: 'test-bucket', directories: ['dist/apps/test-app'], gzip: false },
{ root: 'test-root' } as never
)

expect(execCommandMock).not.toHaveBeenCalled()
})

it('should upload with directories', () => {
uploadExecutor(
{ bucket: 'test-bucket', directories: ['dist/apps/test-app:/test-app'], gzip: false },
{ root: 'test-root' } as never
)

expect(execCommandMock).toHaveBeenCalled()
expect(execCommandMock).toHaveBeenCalledWith(
`gsutil rsync -R ${workspaceRoot}/test-root/dist/apps/test-app gs://test-bucket/test-app`)
})
})
7 changes: 7 additions & 0 deletions packages/gcp-storage/src/executors/upload/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
"type": "string",
"description": "Directory to upload"
},
"directories": {
"type": "array",
"items": {
"type": "string"
},
"description": "Directory to upload"
},
"gzip": {
"type": "boolean",
"description": "Should the files that are uploaded be gzipped",
Expand Down
37 changes: 27 additions & 10 deletions packages/gcp-storage/src/executors/upload/upload.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,53 @@ import { join, resolve } from 'path'

export interface UploadExecutorSchema {
bucket: string
directory: string
directory?: string
directories?: string[]
gzip: boolean
gzipExtensions: string
gzipExtensions?: string
}

export async function uploadExecutor(
options: UploadExecutorSchema,
context: ExecutorContext
): Promise<{ success: boolean }> {
const { directory, gzip = false, gzipExtensions, bucket } = options
const { directory, directories, gzip = false, gzipExtensions, bucket } = options

if (!directory) {
if (!directory && (!directories || directories.length === 0)) {
throw new Error('"directory" is required!')
}

const directoryToUpload = join(context.root, directory)
const uploadDirectories = directories || [`${directory}:/`]

const uploadTo = `gs://${bucket}`
let success = true
for (const uploadDirectory of uploadDirectories) {
if (!uploadDirectory.includes(':')) {
logger.error(`Invalid upload directory "${uploadDirectory}", must be in format "localPath:bucketPath"`)
success = false
break
}

logger.info(`Start upload assets from "${directoryToUpload}" to "${uploadTo}"`)
const [localPath, bucketPath] = uploadDirectory.split(':')
const directoryToUpload = join(context.root, localPath)
const uploadTo = `gs://${bucket}${bucketPath}`

return Promise.resolve(
execCommand(buildCommand([
logger.info(`Start upload assets from "${directoryToUpload}" to "${uploadTo}"`)

const result = execCommand(buildCommand([
'gsutil rsync -R',
gzip && `-z "${gzipExtensions}"`,

resolve(process.cwd(), directoryToUpload),
uploadTo
]))
)

if (!result.success) {
success = false
break
}
}

return { success }
}

export default uploadExecutor
2 changes: 1 addition & 1 deletion packages/gcp-task-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "8.1.0",
"main": "src/index.js",
"dependencies": {
"@google-cloud/storage": "7.13.0"
"@google-cloud/storage": "7.14.0"
},
"peerDependencies": {
"@nx/devkit": "^20.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/pulumi/gcp/resources/bucket.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class BucketResource extends BaseResource {
})
}

public get name() {
public get name(): pulumi.Output<string> {
return this.bucket.name
}

Expand Down
3 changes: 3 additions & 0 deletions packages/pulumi/gcp/resources/secret.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export class SecretResource extends BaseResource {
new gcp.secretmanager.SecretVersion(buildName(this.secretName, 'secret-version'), {
secret: this.secret.id,
secretData: typeof secretValue === 'string' ? secretValue : JSON.stringify(secretValue)
}, {
parent: this.secret,
aliases: [{ parent: pulumi.rootStackResource }]
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pulumi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@pulumi/pulumi": "^3.129.0"
},
"optionalDependencies": {
"@pulumi/gcp": "^8.6.0"
"@pulumi/gcp": "^8.10.0"
},
"builders": "./executors.json",
"generators": "./generators.json"
Expand Down
4 changes: 2 additions & 2 deletions packages/react-email/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"license": "MIT",
"main": "src/index.js",
"devDependencies": {
"@react-email/components": "0.0.25",
"react-email": "3.0.1"
"@react-email/components": "0.0.28",
"react-email": "3.0.2"
},
"peerDependencies": {
"@nx/devkit": "^20.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/shadcn-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"devDependencies": {
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"lucide-react": "^0.453.0",
"lucide-react": "^0.460.0",
"tailwind-merge": "^2.5.4",
"tailwindcss-animate": "^1.0.7"
},
Expand Down
38 changes: 19 additions & 19 deletions packages/shadcn-ui/src/executors/add/add.impl.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { ExecutorContext } from '@nx/devkit'
import { buildCommand, execPackageManagerCommand } from '@nx-extend/core'
import { workspaceRoot } from '@nx/devkit'
import { buildCommand, getPackageManagerDlxCommand } from '@nx-extend/core'
import { execSync } from 'child_process'

export interface ExecutorSchema {
component?: string
overwrite?: boolean
}

export async function addExecutor(
options: ExecutorSchema,
context: ExecutorContext
): Promise<{ success: boolean }> {
return execPackageManagerCommand(
buildCommand([
'shadcn@latest add',
(options.component ?? '').length === 0 ? '--all' : options.component,
options.overwrite && '--overwrite'
]),
{
env: {
...process.env,
TS_NODE_PROJECT: 'tsconfig.base.json'
}
}
)
export async function addExecutor(options: ExecutorSchema): Promise<{ success: boolean }> {
execSync(buildCommand([
getPackageManagerDlxCommand(),
'shadcn@latest add',
(options.component ?? '').length === 0 ? '--all' : options.component,
options.overwrite && '--overwrite'
]), {
cwd: workspaceRoot,
env: {
...process.env,
TS_NODE_PROJECT: 'tsconfig.base.json'
},
stdio: 'inherit'
})

return { success: true }
}

export default addExecutor
5 changes: 3 additions & 2 deletions packages/shadcn-ui/src/generators/init/init.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ export default async function (tree: Tree, options: ShadecnUiSchema) {
'cssVariables': true
},
'aliases': {
'components': uiLibOptions.importPath,
'ui': uiLibOptions.importPath,
'components': `${uiLibOptions.importPath}/components`,
'utils': utilsLibOptions.importPath,
"hooks": `${uiLibOptions.importPath}/hooks`
'hooks': `${uiLibOptions.importPath}/hooks`
}
})

Expand Down
4 changes: 2 additions & 2 deletions packages/vercel/src/executors/build/build.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface BuildOptions {
buildTarget?: string
framework?: string
outputPath?: string
nodeVersion?: '16.x'
nodeVersion?: '20.x' | '22.x'
config: string
}

Expand Down Expand Up @@ -115,7 +115,7 @@ export function buildExecutor(
outputDirectory: getOutputDirectory(framework, outputDirectory),
rootDirectory: null,
directoryListing: false,
nodeVersion: options.nodeVersion || '20.x'
nodeVersion: options.nodeVersion || '22.x'
}
})

Expand Down
8 changes: 8 additions & 0 deletions packages/vercel/src/executors/build/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
"remix",
"other"
]
},
"nodeVersion": {
"type": "string",
"description": "What version of node to configure",
"enum": [
"20.x",
"22.x"
]
}
},
"required": [
Expand Down
Loading
Loading