-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rust): provide needed information to build the project graph
- Loading branch information
Showing
25 changed files
with
1,209 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# path to a directory with all packages | ||
storage: ../tmp/local-registry/storage | ||
|
||
auth: | ||
htpasswd: | ||
file: ./htpasswd | ||
algorithm: bcrypt | ||
|
||
# a list of other known repositories we can talk to | ||
uplinks: | ||
npmjs: | ||
url: https://registry.npmjs.org/ | ||
maxage: 60m | ||
max_fails: 20 | ||
fail_timeout: 2m | ||
yarn: | ||
url: https://registry.yarnpkg.com | ||
maxage: 60m | ||
max_fails: 20 | ||
fail_timeout: 2 | ||
|
||
packages: | ||
'@*/*': | ||
# scoped packages | ||
access: $all | ||
publish: $all | ||
unpublish: $all | ||
proxy: npmjs | ||
|
||
'**': | ||
# give all users (including non-authenticated users) full access | ||
# because it is a local registry | ||
access: $all | ||
publish: $all | ||
unpublish: $all | ||
|
||
# if package is not available locally, proxy requests to npm registry | ||
proxy: npmjs | ||
|
||
# log settings | ||
logs: | ||
type: stdout | ||
format: pretty | ||
level: warn | ||
|
||
publish: | ||
allow_offline: true # set offline to true to allow publish offline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
test:$2y$10$lVWrhBqHffH6dnroJWR.0ug.Zgehrsxdh0dRcrFSqdktWqf/sRk9S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* 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', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { ProjectGraph } from '@nx/devkit'; | ||
import { execSync } from 'child_process'; | ||
import { mkdirSync, readFileSync, rmSync } from 'fs'; | ||
import { dirname, join } from 'path'; | ||
|
||
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(`npm install @monodon/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 @monodon/rust', { | ||
cwd: projectDirectory, | ||
stdio: 'inherit', | ||
}); | ||
}); | ||
|
||
it('should generate a cargo project and update the project graph', () => { | ||
runNxCommand(`generate @monodon/rust:bin hello-world`, projectDirectory); | ||
runNxCommand(`generate @monodon/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/cache/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", | ||
}, | ||
] | ||
`); | ||
}); | ||
}); | ||
|
||
function runNxCommand(command: string, projectDir: string) { | ||
execSync(`npx nx ${command}`, { cwd: projectDir, stdio: 'inherit' }); | ||
} | ||
|
||
/** | ||
* Creates a test project with create-nx-workspace and installs the plugin | ||
* @returns The directory where the test project was created | ||
*/ | ||
function createTestProject() { | ||
const projectName = 'test-project'; | ||
const projectDirectory = join(process.cwd(), 'tmp', 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 --no-nxCloud --no-interactive`, | ||
{ | ||
cwd: dirname(projectDirectory), | ||
stdio: 'inherit', | ||
env: process.env, | ||
} | ||
); | ||
console.log(`Created test project in "${projectDirectory}"`); | ||
|
||
return projectDirectory; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.