This commit is contained in:
병준 박 2025-05-06 16:57:11 +00:00
parent 18932f4a5f
commit e27c094202
163 changed files with 11786 additions and 9717 deletions

View File

@ -1,4 +0,0 @@
{
"extends": ["@commitlint/config-conventional"],
"rules": {}
}

View File

@ -6,7 +6,8 @@
"workspaceFolder": "/workspace", "workspaceFolder": "/workspace",
"shutdownAction": "stopCompose", "shutdownAction": "stopCompose",
"features": { "features": {
"ghcr.io/devcontainers/features/node:1": {}, // "ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers-extra/features/typescript:2": {},
"ghcr.io/devcontainers/features/docker-in-docker:2": {} "ghcr.io/devcontainers/features/docker-in-docker:2": {}
}, },
// Configure tool-specific properties. // Configure tool-specific properties.
@ -40,7 +41,7 @@
// Use 'forwardPorts' to make a list of ports inside the container available locally. // Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [], // "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created. // Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "/bin/sh ./.devcontainer/postCreateCommand.sh", "postCreateCommand": "/bin/bash ./.devcontainer/postCreateCommand.sh",
"mounts": [ "mounts": [
"source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached", "source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,consistency=cached",
"source=${localEnv:HOME}/.netrc,target=/home/vscode/.netrc,type=bind,consistency=cached", "source=${localEnv:HOME}/.netrc,target=/home/vscode/.netrc,type=bind,consistency=cached",

View File

@ -1,3 +1,14 @@
npm install -g npm #!/bin/bash
npm add --global nx@latest set -ex
wget -qO- https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -
export PNPM_HOME="$HOME/.local/share/pnpm"
case ":$PATH:" in
*":$PNPM_HOME:"*) ;;
*) export PATH="$PNPM_HOME:$PATH" ;;
esac
SHELL=/bin/bash pnpm setup
pnpm add -g nx@latest

View File

@ -1,13 +0,0 @@
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
max_line_length = off
trim_trailing_whitespace = false

4
.env
View File

@ -1,4 +0,0 @@
# Nx 18 enables using plugins to infer targets by default
# This is disabled for existing workspaces to maintain compatibility
# For more info, see: https://nx.dev/concepts/inferred-tasks
NX_ADD_PLUGINS=false

View File

@ -1 +0,0 @@
node_modules

View File

@ -1,48 +0,0 @@
{
"root": true,
"ignorePatterns": ["**/*"],
"plugins": ["@nx"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nx/typescript"],
"rules": {
"@typescript-eslint/no-explicit-any": "warn",
"@typescript-eslint/no-unused-vars": "warn",
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": ["*.js", "*.jsx"],
"extends": ["plugin:@nx/javascript"],
"rules": {
"@typescript-eslint/no-extra-semi": "error",
"no-extra-semi": "off"
}
},
{
"files": "*.json",
"parser": "jsonc-eslint-parser",
"rules": {}
}
]
}

View File

@ -1,24 +0,0 @@
name: CI
on:
push:
branches:
- main
pull_request:
env:
node_version: 20
jobs:
checks:
runs-on: ubuntu-latest
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/workflows/setup
with:
node_version: ${{ env.node_version }}
- run: yarn nx run-many --target=build,test,lint --exclude loafle --parallel --max-parallel=3
- run: yarn nx run-many --target=e2e --exclude loafle --parallel
- run: yarn nx-cloud stop-all-agents

View File

@ -1,27 +0,0 @@
name: Setup
description: Setup tasks
inputs:
node_version: # id of input
description: 'Version of node to use'
required: true
default: '20'
runs:
using: 'composite'
steps:
- name: Derive appropriate SHAs for base and head for `nx affected` commands
uses: nrwl/nx-set-shas@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node_version}}
- name: Install
uses: dtolnay/rust-toolchain@1.79.0
- uses: actions/cache@v4
id: workspace-cache
with:
path: node_modules
key: ${{ runner.os }}-${{ inputs.node_version }}-workspace-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ inputs.node_version }}-workspace-
- run: yarn install --frozen-lockfile
shell: bash

279
.gitignore vendored
View File

@ -1,47 +1,270 @@
# See http://help.github.com/ignore-files/ for more about ignoring files. # Created by https://www.toptal.com/developers/gitignore/api/node,linux,macos,windows,visualstudiocode,angular
# Edit at https://www.toptal.com/developers/gitignore?templates=node,linux,macos,windows,visualstudiocode,angular
### Angular ###
## Angular ##
# compiled output # compiled output
/dist dist/
tmp tmp/
/out-tsc app/**/*.js
app/**/*.js.map
# dependencies # dependencies
/node_modules node_modules/
bower_components/
# IDEs and editors # IDEs and editors
/.idea .idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode # misc
.sass-cache/
connect.lock/
coverage/
libpeerconnection.log/
npm-debug.log
testem.log
typings/
.angular/
.pnpm-store
# e2e
e2e/*.js
e2e/*.map
# System Files
.DS_Store/
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### macOS Patch ###
# iCloud generated files
*.icloud
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
!.devcontainer/.env
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### Node Patch ###
# Serverless Webpack directories
.webpack/
# Optional stylelint cache
# SvelteKit build / generate output
.svelte-kit
### VisualStudioCode ###
.vscode/* .vscode/*
!.vscode/settings.json !.vscode/settings.json
!.vscode/tasks.json !.vscode/tasks.json
!.vscode/launch.json !.vscode/launch.json
!.vscode/extensions.json !.vscode/extensions.json
!.vscode/*.code-snippets
# misc # Local History for Visual Studio Code
/.sass-cache .history/
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files # Built Visual Studio Code Extensions
.DS_Store *.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### Windows ###
# Windows thumbnail cache files
Thumbs.db Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Added by cargo # Folder config file
[Dd]esktop.ini
/target # Recycle Bin used on file shares
$RECYCLE.BIN/
.nx/cache # Windows Installer files
.nx/workspace-data *.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# End of https://www.toptal.com/developers/gitignore/api/node,linux,macos,windows,visualstudiocode,angular

View File

@ -1,4 +0,0 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx --no-install commitlint --edit $1

View File

@ -1 +0,0 @@
test:$2y$10$lVWrhBqHffH6dnroJWR.0ug.Zgehrsxdh0dRcrFSqdktWqf/sRk9S

View File

@ -1,6 +0,0 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"eslint.validate": [
"json"
]
}

View File

@ -1,14 +1,5 @@
<p align="center"> npx create-nx-workspace nx-plugin --preset=ts --pm=pnpm
<img width="256px" src="./assets/monodon.png" />
</p>
<div align="center">
# Monodon npx nx g @nx/js:lib packages/rust --useProjectJson=true
**A collection of utilities and plugins for the Nx ecosystem** npx nx g @nx/js:lib packages/rust --publishable --importPath=@loafle/nx-rust --useProjectJson=true
</div>
[![npm (scoped)](https://img.shields.io/static/v1?label=%20&message=README&logo=markdown&style=for-the-badge)](./packages/rust/README.md)
[![npm (scoped)](https://img.shields.io/npm/v/@loafle/nx-rust?label=rust&logo=Rust&style=for-the-badge)](https://www.npmjs.com/package/@loafle/nx-rust)<br/>
[![npm (scoped)](https://img.shields.io/static/v1?label=%20&message=README&logo=markdown&style=for-the-badge)](./packages/rust/README.md)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 451 KiB

View File

@ -1,18 +0,0 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@ -1,12 +0,0 @@
/* eslint-disable */
export default {
displayName: 'rust-e2e',
preset: '../../jest.preset.js',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../coverage/e2e/rust-e2e',
globalSetup: '../../tools/scripts/start-local-registry.ts',
globalTeardown: '../../tools/scripts/stop-local-registry.ts',
};

View File

@ -1,22 +0,0 @@
{
"name": "rust-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"projectType": "application",
"sourceRoot": "e2e/rust-e2e/src",
"targets": {
"e2e": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
"options": {
"jestConfig": "e2e/rust-e2e/jest.config.ts",
"runInBand": true
},
"dependsOn": ["^build"]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
}
},
"implicitDependencies": ["rust"]
}

View File

@ -1,69 +0,0 @@
import { execSync } from 'child_process';
import { createTestProject, runNxCommand } from './utils';
import { rmSync } from 'fs';
import { listFiles, readFile, updateFile } from '@nx/plugin/testing';
describe('napi', () => {
let projectDirectory: string;
beforeAll(() => {
projectDirectory = createTestProject('napi');
// The plugin has been built and published to a local registry in the jest globalSetup
// Install the plugin built with the latest source code into the test repo
execSync(`yarn add -D @loafle/nx-rust@e2e`, {
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
});
});
afterAll(() => {
// Cleanup the test project
rmSync(projectDirectory, {
recursive: true,
force: true,
});
});
it('should create a napi project', () => {
runNxCommand(
`generate @loafle/nx-rust:lib napi-proj --napi`,
projectDirectory
);
const projectConfigPath = `test-project-napi/napi_proj/project.json`;
const projectFile = JSON.parse(readFile(projectConfigPath));
projectFile['targets']['build']['options'] = {
...projectFile['targets']['build']['options'],
jsFile: 'native.js',
dts: 'native.d.ts',
};
updateFile(projectConfigPath, JSON.stringify(projectFile, null, 2));
expect(listFiles(`test-project-napi/napi_proj/npm`).length).toBeGreaterThan(
0
);
expect(() =>
runNxCommand(`build napi_proj`, projectDirectory)
).not.toThrow();
const files = listFiles(`test-project-napi/napi_proj`);
expect(files.some((file) => file.endsWith('native.js'))).toBeTruthy();
expect(files.some((file) => file.endsWith('native.d.ts'))).toBeTruthy();
expect(files.some((file) => file.endsWith('.node'))).toBeTruthy();
expect(() =>
runNxCommand(
`build napi_proj -- --target wasm32-wasip1-threads`,
projectDirectory
)
).not.toThrow();
const files2 = listFiles(`test-project-napi/napi_proj`);
expect(
files2.some((file) => file.endsWith('wasm32-wasi.wasm'))
).toBeTruthy();
expect(files2).toContain('wasi-worker.mjs');
expect(files2).toContain('wasi-worker-browser.mjs');
});
});

View File

@ -1,75 +0,0 @@
import { ProjectGraph } from '@nx/devkit';
import { execSync } from 'child_process';
import { readFileSync, rmSync } from 'fs';
import { join } from 'path';
import { createTestProject, runNxCommand } from './utils';
describe('rust', () => {
let projectDirectory: string;
beforeAll(() => {
projectDirectory = createTestProject();
// The plugin has been built and published to a local registry in the jest globalSetup
// Install the plugin built with the latest source code into the test repo
execSync(`yarn add -D @loafle/nx-rust@e2e`, {
cwd: projectDirectory,
stdio: 'inherit',
env: process.env,
});
});
afterAll(() => {
// Cleanup the test project
rmSync(projectDirectory, {
recursive: true,
force: true,
});
});
it('should be installed', () => {
// npm ls will fail if the package is not installed properly
execSync('npm ls @loafle/nx-rust', {
cwd: projectDirectory,
stdio: 'inherit',
});
});
it('should generate a cargo project and update the project graph', () => {
runNxCommand(`generate @loafle/nx-rust:bin hello-world`, projectDirectory);
runNxCommand(`generate @loafle/nx-rust:lib lib1`, projectDirectory);
execSync('cargo add itertools -p lib1', { cwd: projectDirectory });
execSync(`cargo add lib1 --path ./lib1 -p hello_world`, {
cwd: projectDirectory,
});
expect(() =>
runNxCommand(`build hello_world`, projectDirectory)
).not.toThrow();
const projectGraph: ProjectGraph = JSON.parse(
readFileSync(
join(projectDirectory, '.nx/workspace-data/project-graph.json')
).toString()
);
expect(projectGraph.dependencies['hello_world']).toMatchInlineSnapshot(`
Array [
Object {
"source": "hello_world",
"target": "lib1",
"type": "static",
},
]
`);
expect(projectGraph.dependencies['lib1']).toMatchInlineSnapshot(`
Array [
Object {
"source": "lib1",
"target": "cargo:itertools",
"type": "static",
},
]
`);
});
});

View File

@ -1,38 +0,0 @@
import { dirname, join } from 'path';
import { mkdirSync, rmSync } from 'fs';
import { execSync } from 'child_process';
import { tmpProjPath } from '@nx/plugin/testing';
/**
* Creates a test project with create-nx-workspace and installs the plugin
* @returns The directory where the test project was created
*/
export function createTestProject(testId = '') {
const projectName = 'test-project-' + testId;
const projectDirectory = tmpProjPath(projectName);
// Ensure projectDirectory is empty
rmSync(projectDirectory, {
recursive: true,
force: true,
});
mkdirSync(dirname(projectDirectory), {
recursive: true,
});
execSync(
`npx --yes create-nx-workspace@latest ${projectName} --preset apps --nxCloud=skip --no-interactive --packageManager yarn`,
{
cwd: dirname(projectDirectory),
stdio: 'inherit',
env: process.env,
}
);
console.log(`Created test project in "${projectDirectory}"`);
return projectDirectory;
}
export function runNxCommand(command: string, projectDir: string) {
execSync(`npx nx ${command}`, { cwd: projectDir, stdio: 'inherit' });
}

View File

@ -1,14 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"jest.config.ts",
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.d.ts"
]
}

View File

@ -1,15 +0,0 @@
const nxPreset = require('@nx/jest/preset').default;
module.exports = {
...nxPreset,
/* TODO: Update to latest Jest snapshotFormat
* By default Nx has kept the older style of Jest Snapshot formats
* to prevent breaking of any existing tests with snapshots.
* It's recommend you update to the latest format.
* You can do this by removing snapshotFormat property
* and running tests with --update-snapshot flag.
* Example: "nx affected --targets=e2e --update-snapshot"
* More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
*/
snapshotFormat: { escapeString: true, printBasicPrototype: true },
};

View File

@ -1,27 +0,0 @@
{
"migrations": [
{
"version": "20.0.0-beta.7",
"description": "Migration for v20.0.0-beta.7",
"implementation": "./src/migrations/update-20-0-0/move-use-daemon-process",
"package": "nx",
"name": "move-use-daemon-process"
},
{
"version": "20.0.1",
"description": "Set `useLegacyCache` to true for migrating workspaces",
"implementation": "./src/migrations/update-20-0-1/use-legacy-cache",
"x-repair-skip": true,
"package": "nx",
"name": "use-legacy-cache"
},
{
"cli": "nx",
"version": "20.0.0-beta.5",
"description": "replace getJestProjects with getJestProjectsAsync",
"implementation": "./src/migrations/update-20-0-0/replace-getJestProjects-with-getJestProjectsAsync",
"package": "@nx/jest",
"name": "replace-getJestProjects-with-getJestProjectsAsync"
}
]
}

44
nx-plugin/.gitignore vendored Normal file
View File

@ -0,0 +1,44 @@
# See https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
# compiled output
dist
tmp
out-tsc
# dependencies
node_modules
# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace
# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings
# System Files
.DS_Store
Thumbs.db
.nx/cache
.nx/workspace-data
test-output

2
nx-plugin/.npmrc Normal file
View File

@ -0,0 +1,2 @@
strict-peer-dependencies=false
auto-install-peers=true

View File

@ -1,7 +1,5 @@
# Add files here to ignore them from prettier formatting # Add files here to ignore them from prettier formatting
/dist /dist
/coverage /coverage
/.nx/cache /.nx/cache
/.nx/workspace-data /.nx/workspace-data

View File

@ -1,32 +1,13 @@
# path to a directory with all packages # path to a directory with all packages
storage: ../tmp/local-registry/storage storage: ../tmp/local-registry/storage
auth:
htpasswd:
file: ./htpasswd
algorithm: bcrypt
# a list of other known repositories we can talk to # a list of other known repositories we can talk to
uplinks: uplinks:
npmjs: npmjs:
url: https://registry.npmjs.org/ url: https://registry.npmjs.org/
maxage: 60m maxage: 60m
max_fails: 20
fail_timeout: 2m
yarn:
url: https://registry.yarnpkg.com
maxage: 60m
max_fails: 20
fail_timeout: 2
packages: packages:
'@*/*':
# scoped packages
access: $all
publish: $all
unpublish: $all
proxy: npmjs
'**': '**':
# give all users (including non-authenticated users) full access # give all users (including non-authenticated users) full access
# because it is a local registry # because it is a local registry
@ -38,7 +19,7 @@ packages:
proxy: npmjs proxy: npmjs
# log settings # log settings
logs: log:
type: stdout type: stdout
format: pretty format: pretty
level: warn level: warn

90
nx-plugin/README.md Normal file
View File

@ -0,0 +1,90 @@
# NxPlugin
<a alt="Nx logo" href="https://nx.dev" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-logo.png" width="45"></a>
✨ Your new, shiny [Nx workspace](https://nx.dev) is almost ready ✨.
[Learn more about this workspace setup and its capabilities](https://nx.dev/nx-api/js?utm_source=nx_project&amp;utm_medium=readme&amp;utm_campaign=nx_projects) or run `npx nx graph` to visually explore what was created. Now, let's get you up to speed!
## Finish your remote caching setup
[Click here to finish setting up your workspace!](https://cloud.nx.app/connect/q0GJIavnf2)
## Generate a library
```sh
npx nx g @nx/js:lib packages/pkg1 --publishable --importPath=@my-org/pkg1
```
## Run tasks
To build the library use:
```sh
npx nx build pkg1
```
To run any task with Nx use:
```sh
npx nx <target> <project-name>
```
These targets are either [inferred automatically](https://nx.dev/concepts/inferred-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects) or defined in the `project.json` or `package.json` files.
[More about running tasks in the docs &raquo;](https://nx.dev/features/run-tasks?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## Versioning and releasing
To version and release the library use
```
npx nx release
```
Pass `--dry-run` to see what would happen without actually releasing the library.
[Learn more about Nx release &raquo;](hhttps://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## Keep TypeScript project references up to date
Nx automatically updates TypeScript [project references](https://www.typescriptlang.org/docs/handbook/project-references.html) in `tsconfig.json` files to ensure they remain accurate based on your project dependencies (`import` or `require` statements). This sync is automatically done when running tasks such as `build` or `typecheck`, which require updated references to function correctly.
To manually trigger the process to sync the project graph dependencies information to the TypeScript project references, run the following command:
```sh
npx nx sync
```
You can enforce that the TypeScript project references are always in the correct state when running in CI by adding a step to your CI job configuration that runs the following command:
```sh
npx nx sync:check
```
[Learn more about nx sync](https://nx.dev/reference/nx-commands#sync)
[Learn more about Nx on CI](https://nx.dev/ci/intro/ci-with-nx#ready-get-started-with-your-provider?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## Install Nx Console
Nx Console is an editor extension that enriches your developer experience. It lets you run tasks, generate code, and improves code autocompletion in your IDE. It is available for VSCode and IntelliJ.
[Install Nx Console &raquo;](https://nx.dev/getting-started/editor-setup?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
## Useful links
Learn more:
- [Learn more about this workspace setup](https://nx.dev/nx-api/js?utm_source=nx_project&amp;utm_medium=readme&amp;utm_campaign=nx_projects)
- [Learn about Nx on CI](https://nx.dev/ci/intro/ci-with-nx?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [Releasing Packages with Nx release](https://nx.dev/features/manage-releases?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
- [What are Nx plugins?](https://nx.dev/concepts/nx-plugins?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)
And join the Nx community:
- [Discord](https://go.nx.dev/community)
- [Follow us on X](https://twitter.com/nxdevtools) or [LinkedIn](https://www.linkedin.com/company/nrwl)
- [Our Youtube channel](https://www.youtube.com/@nxdevtools)
- [Our blog](https://nx.dev/blog?utm_source=nx_project&utm_medium=readme&utm_campaign=nx_projects)

View File

@ -0,0 +1,42 @@
import nx from '@nx/eslint-plugin';
export default [
...nx.configs['flat/base'],
...nx.configs['flat/typescript'],
...nx.configs['flat/javascript'],
{
ignores: ['**/dist'],
},
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
rules: {
'@nx/enforce-module-boundaries': [
'error',
{
enforceBuildableLibDependency: true,
allow: ['^.*/eslint(\\.base)?\\.config\\.[cm]?js$'],
depConstraints: [
{
sourceTag: '*',
onlyDependOnLibsWithTags: ['*'],
},
],
},
],
},
},
{
files: [
'**/*.ts',
'**/*.tsx',
'**/*.cts',
'**/*.mts',
'**/*.js',
'**/*.jsx',
'**/*.cjs',
'**/*.mjs',
],
// Override or add rules here
rules: {},
},
];

View File

@ -1,5 +1,6 @@
import type { Config } from 'jest';
import { getJestProjectsAsync } from '@nx/jest'; import { getJestProjectsAsync } from '@nx/jest';
export default async () => ({ export default async (): Promise<Config> => ({
projects: await getJestProjectsAsync(), projects: await getJestProjectsAsync(),
}); });

3
nx-plugin/jest.preset.js Normal file
View File

@ -0,0 +1,3 @@
const nxPreset = require('@nx/jest/preset').default;
module.exports = { ...nxPreset };

61
nx-plugin/nx.json Normal file
View File

@ -0,0 +1,61 @@
{
"$schema": "./node_modules/nx/schemas/nx-schema.json",
"namedInputs": {
"default": ["{projectRoot}/**/*", "sharedGlobals"],
"production": [
"default",
"!{projectRoot}/.eslintrc.json",
"!{projectRoot}/eslint.config.mjs",
"!{projectRoot}/**/?(*.)+(spec|test).[jt]s?(x)?(.snap)",
"!{projectRoot}/tsconfig.spec.json",
"!{projectRoot}/jest.config.[jt]s",
"!{projectRoot}/src/test-setup.[jt]s",
"!{projectRoot}/test-setup.[jt]s"
],
"sharedGlobals": []
},
"nxCloudId": "681a30f54a2481208e0ed2ab",
"plugins": [
{
"plugin": "@nx/js/typescript",
"options": {
"typecheck": {
"targetName": "typecheck"
},
"build": {
"targetName": "build",
"configName": "tsconfig.lib.json",
"buildDepsName": "build-deps",
"watchDepsName": "watch-deps"
}
}
},
{
"plugin": "@nx/eslint/plugin",
"options": {
"targetName": "lint"
}
},
{
"plugin": "@nx/jest/plugin",
"options": {
"targetName": "test"
}
}
],
"targetDefaults": {
"test": {
"dependsOn": ["^build"]
},
"@nx/js:swc": {
"cache": true,
"dependsOn": ["^build"],
"inputs": ["production", "^production"]
}
},
"release": {
"version": {
"preVersionCommand": "pnpm dlx nx run-many -t build"
}
}
}

53
nx-plugin/package.json Normal file
View File

@ -0,0 +1,53 @@
{
"name": "@loafle/nx-plugin",
"version": "0.0.0",
"license": "MIT",
"scripts": {},
"private": true,
"dependencies": {
"@ltd/j-toml": "1.38.0",
"@napi-rs/cli": "3.0.0-alpha.63",
"@nx/devkit": "20.0.1",
"@nx/js": "21.0.0",
"@swc/helpers": "0.5.13",
"chalk": "^4.1.2"
},
"devDependencies": {
"@commitlint/cli": "17.3.0",
"@commitlint/config-conventional": "17.3.0",
"@eslint/js": "^9.8.0",
"@nx/eslint": "21.0.0",
"@nx/eslint-plugin": "21.0.0",
"@nx/jest": "21.0.0",
"@nx/js": "21.0.0",
"@nx/node": "20.0.1",
"@nx/plugin": "20.0.1",
"@nx/workspace": "20.0.1",
"@swc-node/register": "~1.9.1",
"@swc/cli": "0.3.14",
"@swc/core": "~1.5.7",
"@swc/helpers": "~0.5.17",
"@swc/jest": "~0.2.36",
"@types/jest": "^29.5.12",
"@types/node": "18.16.9",
"@types/semver": "^7.5.8",
"dotenv": "~10.0.0",
"eslint": "^9.8.0",
"eslint-config-prettier": "^10.0.0",
"jest": "^29.7.0",
"jest-environment-node": "^29.7.0",
"jsonc-eslint-parser": "^2.1.0",
"nx": "21.0.0",
"prettier": "^2.6.2",
"semver": "7.5.4",
"ts-jest": "^29.1.0",
"ts-node": "10.9.1",
"tslib": "^2.3.0",
"typescript": "~5.7.2",
"typescript-eslint": "^8.19.0",
"verdaccio": "^6.0.5"
},
"nx": {
"includedScripts": []
}
}

View File

@ -0,0 +1,22 @@
{
"jsc": {
"target": "es2017",
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
},
"keepClassNames": true,
"externalHelpers": true,
"loose": true
},
"module": {
"type": "es6"
},
"sourceMaps": true,
"exclude": []
}

View File

@ -0,0 +1,11 @@
# rust
This library was generated with [Nx](https://nx.dev).
## Building
Run `nx build rust` to build the library.
## Running unit tests
Run `nx test rust` to execute the unit tests via [Jest](https://jestjs.io).

View File

@ -0,0 +1,19 @@
import baseConfig from '../../eslint.config.mjs';
export default [
...baseConfig,
{
files: ['**/*.json'],
rules: {
'@nx/dependency-checks': [
'error',
{
ignoredFiles: ['{projectRoot}/eslint.config.{js,cjs,mjs}'],
},
],
},
languageOptions: {
parser: await import('jsonc-eslint-parser'),
},
},
];

View File

@ -8,9 +8,7 @@
"schema": "./src/generators/binary/schema.json", "schema": "./src/generators/binary/schema.json",
"description": "Generate a Rust bin with Cargo", "description": "Generate a Rust bin with Cargo",
"x-type": "application", "x-type": "application",
"aliases": [ "aliases": ["bin"]
"bin"
]
}, },
"init": { "init": {
"factory": "./src/generators/init/generator", "factory": "./src/generators/init/generator",
@ -23,9 +21,7 @@
"schema": "./src/generators/library/schema.json", "schema": "./src/generators/library/schema.json",
"description": "Generate a Rust library with Cargo", "description": "Generate a Rust library with Cargo",
"x-type": "library", "x-type": "library",
"aliases": [ "aliases": ["lib"]
"lib"
]
}, },
"add-wasm": { "add-wasm": {
"factory": "./src/generators/add-wasm/generator", "factory": "./src/generators/add-wasm/generator",

View File

@ -0,0 +1,21 @@
/* eslint-disable */
import { readFileSync } from 'fs';
// Reading the SWC compilation config for the spec files
const swcJestConfig = JSON.parse(
readFileSync(`${__dirname}/.spec.swcrc`, 'utf-8')
);
// Disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves
swcJestConfig.swcrc = false;
export default {
displayName: '@loafle/nx-rust',
preset: '../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['@swc/jest', swcJestConfig],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: 'test-output/jest/coverage',
};

View File

@ -1,13 +1,14 @@
{ {
"name": "@loafle/nx-rust", "name": "@loafle/nx-rust",
"version": "0.0.0-updated-during-release", "version": "0.0.1",
"main": "src/index.js", "private": false,
"repository": { "repository": {
"url": "https://git.loafle.net/loafle/nx", "url": "https://git.loafle.net/loafle/nx",
"type": "git" "type": "git"
}, },
"license": "MIT", "publishConfig": {
"private": false, "registry": "http://nexus.unbox-x.net/repository/npm-hosted/"
},
"generators": "./generators.json", "generators": "./generators.json",
"executors": "./executors.json", "executors": "./executors.json",
"dependencies": { "dependencies": {
@ -16,7 +17,7 @@
"chalk": "^4.1.2", "chalk": "^4.1.2",
"npm-run-path": "^4.0.1", "npm-run-path": "^4.0.1",
"semver": "7.5.4", "semver": "7.5.4",
"tslib": "^2.0.0" "tslib": "^2.3.0"
}, },
"peerDependencies": { "peerDependencies": {
"@napi-rs/cli": "^3.0.0-alpha.55" "@napi-rs/cli": "^3.0.0-alpha.55"

View File

@ -1,9 +1,10 @@
{ {
"name": "rust", "name": "@loafle/nx-rust",
"$schema": "../../node_modules/nx/schemas/project-schema.json", "$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/rust/src", "sourceRoot": "packages/rust/src",
"projectType": "library", "projectType": "library",
"tags": [], "tags": [],
"// targets": "to see all targets run: nx show project @loafle/nx-rust --web",
"targets": { "targets": {
"lint": { "lint": {
"executor": "@nx/eslint:lint", "executor": "@nx/eslint:lint",

View File

@ -19,9 +19,6 @@
"target-dir": { "target-dir": {
"type": "string" "type": "string"
}, },
"cwd": {
"type": "string"
},
"toolchain": { "toolchain": {
"type": "string", "type": "string",
"enum": [ "enum": [

View File

@ -77,7 +77,7 @@ describe('add-napi generator', () => {
"release": true, "release": true,
}, },
}, },
"executor": "@loafle/nx-rust:napi", "executor": "@monodon/rust:napi",
"options": Object { "options": Object {
"dist": "test", "dist": "test",
"jsFile": "index.js", "jsFile": "index.js",

View File

@ -60,7 +60,7 @@ export default async function (tree: Tree, options: AddNapiGeneratorSchema) {
build: { build: {
cache: true, cache: true,
outputs: [`{workspaceRoot}/${normalizedOptions.projectRoot}`], outputs: [`{workspaceRoot}/${normalizedOptions.projectRoot}`],
executor: '@loafle/nx-rust:napi', executor: '@monodon/rust:napi',
options: { options: {
dist: normalizedOptions.projectRoot, dist: normalizedOptions.projectRoot,
jsFile: 'index.js', jsFile: 'index.js',

View File

@ -66,7 +66,7 @@ export default async function (
sourceRoot: `${normalizedOptions.projectRoot}/src`, sourceRoot: `${normalizedOptions.projectRoot}/src`,
targets: { targets: {
build: { build: {
executor: '@loafle/nx-rust:build', executor: '@monodon/rust:build',
}, },
}, },
tags: normalizedOptions.parsedTags, tags: normalizedOptions.parsedTags,

Some files were not shown because too many files have changed in this diff Show More