-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Lune require alias to configuration files (#35)
The `.luaurc`, `.luau-analyze.json` and `.vscode/settings.json` now have an entry to configure the lune packages alias (when selecting the lune environment or using the lune tool)
- Loading branch information
1 parent
a1fa333
commit b4735aa
Showing
14 changed files
with
5,156 additions
and
1,645 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
874 changes: 874 additions & 0 deletions
874
__tests__/__recordings__/all-tools-requests_985297451/recording.har
Large diffs are not rendered by default.
Oops, something went wrong.
1,372 changes: 1,372 additions & 0 deletions
1,372
__tests__/__recordings__/default-tools-requests_3963608793/recording.har
Large diffs are not rendered by default.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`all tools creates a foreman.toml 1`] = ` | ||
"[tools] | ||
darklua = { github = "seaofvoices/darklua", version = "=0.13.1"} | ||
luau-lsp = { github = "JohnnyMorganz/luau-lsp", version = "=1.32.3"} | ||
lune = { github = "lune-org/lune", version = "=0.8.8"} | ||
mantle = { github = "blake-mealey/mantle", version = "=0.11.16"} | ||
rojo = { github = "rojo-rbx/rojo", version = "=7.4.4"} | ||
run-in-roblox = { github = "rojo-rbx/run-in-roblox", version = "=0.3.0"} | ||
selene = { github = "Kampfkarren/selene", version = "=0.27.1"} | ||
stylua = { github = "JohnnyMorganz/StyLua", version = "=0.20.0"} | ||
tarmac = { github = "rojo-rbx/tarmac", version = "=0.7.5"} | ||
" | ||
`; | ||
|
||
exports[`default tools creates a foreman.toml 1`] = ` | ||
"[tools] | ||
darklua = { github = "seaofvoices/darklua", version = "=0.13.1"} | ||
luau-lsp = { github = "JohnnyMorganz/luau-lsp", version = "=1.32.3"} | ||
selene = { github = "Kampfkarren/selene", version = "=0.27.1"} | ||
stylua = { github = "JohnnyMorganz/StyLua", version = "=0.20.0"} | ||
" | ||
`; |
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,88 @@ | ||
import { expect, it, describe, jest, beforeEach } from '@jest/globals' | ||
import { getFileContent, setupGenerator, usePolly } from './utils' | ||
|
||
const projectName = 'new-project' | ||
let spawnMock = jest.fn() | ||
let answers = {} | ||
|
||
const setupContext = async () => | ||
await setupGenerator('foreman') | ||
.withArguments([projectName]) | ||
.withAnswers(answers) | ||
.withSpawnMock(spawnMock) | ||
|
||
beforeEach(() => { | ||
spawnMock = jest.fn() | ||
answers = { | ||
tools: [], | ||
} | ||
}) | ||
|
||
describe('default tools', () => { | ||
beforeEach(() => { | ||
usePolly('default-tools-requests') | ||
}) | ||
|
||
it('creates a foreman.toml', async () => { | ||
const context = await setupContext() | ||
|
||
expect(getFileContent(context, 'foreman.toml')).toMatchSnapshot() | ||
}) | ||
|
||
it('runs the foreman install command', async () => { | ||
await setupContext() | ||
|
||
expect(spawnMock).toHaveBeenCalledWith( | ||
'spawnSync', | ||
'foreman', | ||
['install'], | ||
expect.any(Object) | ||
) | ||
}) | ||
}) | ||
|
||
describe('all tools', () => { | ||
beforeEach(async () => { | ||
answers.tools = [ | ||
'selene', | ||
'stylua', | ||
'luau-lsp', | ||
'darklua', | ||
'rojo', | ||
'tarmac', | ||
'run-in-roblox', | ||
'lune', | ||
'mantle', | ||
] | ||
|
||
usePolly('all-tools-requests') | ||
}) | ||
|
||
it('creates a foreman.toml', async () => { | ||
const context = await setupContext() | ||
|
||
expect(getFileContent(context, 'foreman.toml')).toMatchSnapshot() | ||
}) | ||
|
||
it('runs the foreman install command', async () => { | ||
await setupContext() | ||
|
||
expect(spawnMock).toHaveBeenCalledWith( | ||
'spawnSync', | ||
'foreman', | ||
['install'], | ||
expect.any(Object) | ||
) | ||
}) | ||
|
||
it('runs the lune setup command', async () => { | ||
await setupContext() | ||
|
||
expect(spawnMock).toHaveBeenCalledWith( | ||
'spawnSync', | ||
'lune', | ||
['setup'], | ||
expect.any(Object) | ||
) | ||
}) | ||
}) |
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,55 @@ | ||
import { basename, dirname, join } from 'path' | ||
import { afterThis } from 'jest-after-this' | ||
import { fileURLToPath } from 'url' | ||
import helpers from 'yeoman-test' | ||
import { Polly } from '@pollyjs/core' | ||
import NodeHttpAdapter from '@pollyjs/adapter-node-http' | ||
import FSPersister from '@pollyjs/persister-fs' | ||
|
||
export const getFileContent = (context, fileName) => { | ||
const snapshot = context.getSnapshot( | ||
(file) => file.relativePath && basename(file.relativePath) === fileName | ||
) | ||
|
||
const snapshotValues = Object.values(snapshot) | ||
if (snapshotValues.length === 0) { | ||
throw Error(`Unable to find file ${fileName}`) | ||
} | ||
if (snapshotValues.length > 1) { | ||
throw Error(`Found multiple file for ${fileName}`) | ||
} | ||
|
||
return snapshotValues[0].contents | ||
} | ||
|
||
export const usePolly = (recordingName) => { | ||
const location = join( | ||
dirname(fileURLToPath(import.meta.url)), | ||
'__recordings__' | ||
) | ||
|
||
const polly = new Polly(recordingName, { | ||
adapters: [NodeHttpAdapter], | ||
persister: FSPersister, | ||
persisterOptions: { | ||
fs: { | ||
recordingsDir: location, | ||
}, | ||
}, | ||
recordIfMissing: true, | ||
}) | ||
|
||
polly.replay() | ||
|
||
afterThis(() => { | ||
polly.stop() | ||
}) | ||
} | ||
|
||
export const setupGenerator = (generatorName) => | ||
helpers.run( | ||
join( | ||
dirname(fileURLToPath(import.meta.url)), | ||
`../generators/${generatorName}` | ||
) | ||
) |
Oops, something went wrong.