Skip to content

Commit daa4c81

Browse files
committed
fix: formatting with prettier
1 parent b8d4a88 commit daa4c81

File tree

11 files changed

+91
-66
lines changed

11 files changed

+91
-66
lines changed

.prettierignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
# Add files here to ignore them from prettier formatting
22
/dist
3-
/coverage
3+
/coverage
4+
/.nx/cache
5+
/.yarn/releases
6+
/tmp
7+
8+

.verdaccio/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ storage: ../tmp/local-registry/storage
44
# a list of other known repositories we can talk to
55
uplinks:
66
npmjs:
7-
url: http://localhost:4873/
7+
url: https://registry.yarnpkg.com
88
maxage: 60m
99

1010
packages:

jest.preset.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const nxPreset = require('@nx/jest/preset').default
1+
const nxPreset = require('@nx/jest/preset').default;
22

3-
module.exports = { ...nxPreset }
3+
module.exports = { ...nxPreset };

packages/preset-lumberjack-e2e/jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export default {
99
coverageDirectory: '../../coverage/packages/preset-lumberjack-e2e',
1010
globalSetup: '../../tools/scripts/start-local-registry.ts',
1111
globalTeardown: '../../tools/scripts/stop-local-registry.ts',
12-
}
12+
};
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,65 @@
1-
import { execSync } from 'child_process'
2-
import { join, dirname } from 'path'
3-
import { mkdirSync, rmSync } from 'fs'
1+
import { execSync } from 'child_process';
2+
import { join, dirname } from 'path';
3+
import { mkdirSync, rmSync } from 'fs';
44

55
describe('preset-lumberjack', () => {
6-
let projectDirectory: string
6+
let projectDirectory: string;
77

88
beforeAll(() => {
9-
projectDirectory = createTestProject()
9+
projectDirectory = createTestProject();
1010

1111
// The plugin has been built and published to a local registry in the jest globalSetup
1212
// Install the plugin built with the latest source code into the test repo
1313
execSync(`npm install @create-solana-game/preset-lumberjack@e2e`, {
1414
cwd: projectDirectory,
1515
stdio: 'inherit',
1616
env: process.env,
17-
})
18-
})
17+
});
18+
});
1919

2020
afterAll(() => {
2121
// Cleanup the test project
2222
rmSync(projectDirectory, {
2323
recursive: true,
2424
force: true,
25-
})
26-
})
25+
});
26+
});
2727

2828
it('should be installed', () => {
2929
// npm ls will fail if the package is not installed properly
3030
execSync('npm ls @create-solana-game/preset-lumberjack', {
3131
cwd: projectDirectory,
3232
stdio: 'inherit',
33-
})
34-
})
35-
})
33+
});
34+
});
35+
});
3636

3737
/**
3838
* Creates a test project with create-nx-workspace and installs the plugin
3939
* @returns The directory where the test project was created
4040
*/
4141
function createTestProject() {
42-
const projectName = 'test-project'
43-
const projectDirectory = join(process.cwd(), 'tmp', projectName)
42+
const projectName = 'test-project';
43+
const projectDirectory = join(process.cwd(), 'tmp', projectName);
4444

4545
// Ensure projectDirectory is empty
4646
rmSync(projectDirectory, {
4747
recursive: true,
4848
force: true,
49-
})
49+
});
5050
mkdirSync(dirname(projectDirectory), {
5151
recursive: true,
52-
})
52+
});
5353

54-
execSync(`npx --yes create-nx-workspace@latest ${projectName} --preset apps --no-nxCloud --no-interactive`, {
55-
cwd: dirname(projectDirectory),
56-
stdio: 'inherit',
57-
env: process.env,
58-
})
59-
console.log(`Created test project in "${projectDirectory}"`)
54+
execSync(
55+
`npx --yes create-nx-workspace@latest ${projectName} --preset apps --no-nxCloud --no-interactive`,
56+
{
57+
cwd: dirname(projectDirectory),
58+
stdio: 'inherit',
59+
env: process.env,
60+
}
61+
);
62+
console.log(`Created test project in "${projectDirectory}"`);
6063

61-
return projectDirectory
64+
return projectDirectory;
6265
}

packages/preset-lumberjack-e2e/tsconfig.spec.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@
55
"module": "commonjs",
66
"types": ["jest", "node"]
77
},
8-
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
8+
"include": [
9+
"jest.config.ts",
10+
"src/**/*.test.ts",
11+
"src/**/*.spec.ts",
12+
"src/**/*.d.ts"
13+
]
914
}

packages/preset-lumberjack/jest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ export default {
77
},
88
moduleFileExtensions: ['ts', 'js', 'html'],
99
coverageDirectory: '../../coverage/packages/preset-lumberjack',
10-
}
10+
};

packages/preset-lumberjack/tsconfig.spec.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,10 @@
55
"module": "commonjs",
66
"types": ["jest", "node"]
77
},
8-
"include": ["jest.config.ts", "src/**/*.test.ts", "src/**/*.spec.ts", "src/**/*.d.ts"]
8+
"include": [
9+
"jest.config.ts",
10+
"src/**/*.test.ts",
11+
"src/**/*.spec.ts",
12+
"src/**/*.d.ts"
13+
]
914
}

tools/scripts/publish.mjs

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,51 +7,54 @@
77
* You might need to authenticate with NPM before running this script.
88
*/
99

10-
import { execSync } from 'child_process'
11-
import { readFileSync, writeFileSync } from 'fs'
10+
import { execSync } from 'child_process';
11+
import { readFileSync, writeFileSync } from 'fs';
1212

13-
import devkit from '@nx/devkit'
14-
const { readCachedProjectGraph } = devkit
13+
import devkit from '@nx/devkit';
14+
const { readCachedProjectGraph } = devkit;
1515

1616
function invariant(condition, message) {
1717
if (!condition) {
18-
console.error(message)
19-
process.exit(1)
18+
console.error(message);
19+
process.exit(1);
2020
}
2121
}
2222

2323
// Executing publish script: node path/to/publish.mjs {name} --version {version} --tag {tag}
2424
// Default "tag" to "next" so we won't publish the "latest" tag by accident.
25-
const [, , name, version, tag = 'next'] = process.argv
25+
const [, , name, version, tag = 'next'] = process.argv;
2626

2727
// A simple SemVer validation to validate the version
28-
const validVersion = /^\d+\.\d+\.\d+(-\w+\.\d+)?/
28+
const validVersion = /^\d+\.\d+\.\d+(-\w+\.\d+)?/;
2929
invariant(
3030
version && validVersion.test(version),
31-
`No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got ${version}.`,
32-
)
31+
`No version provided or version did not match Semantic Versioning, expected: #.#.#-tag.# or #.#.#, got ${version}.`
32+
);
3333

34-
const graph = readCachedProjectGraph()
35-
const project = graph.nodes[name]
34+
const graph = readCachedProjectGraph();
35+
const project = graph.nodes[name];
3636

37-
invariant(project, `Could not find project "${name}" in the workspace. Is the project.json configured correctly?`)
37+
invariant(
38+
project,
39+
`Could not find project "${name}" in the workspace. Is the project.json configured correctly?`
40+
);
3841

39-
const outputPath = project.data?.targets?.build?.options?.outputPath
42+
const outputPath = project.data?.targets?.build?.options?.outputPath;
4043
invariant(
4144
outputPath,
42-
`Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`,
43-
)
45+
`Could not find "build.options.outputPath" of project "${name}". Is project.json configured correctly?`
46+
);
4447

45-
process.chdir(outputPath)
48+
process.chdir(outputPath);
4649

4750
// Updating the version in "package.json" before publishing
4851
try {
49-
const json = JSON.parse(readFileSync(`package.json`).toString())
50-
json.version = version
51-
writeFileSync(`package.json`, JSON.stringify(json, null, 2))
52+
const json = JSON.parse(readFileSync(`package.json`).toString());
53+
json.version = version;
54+
writeFileSync(`package.json`, JSON.stringify(json, null, 2));
5255
} catch (e) {
53-
console.error(`Error reading package.json file from library build output.`)
56+
console.error(`Error reading package.json file from library build output.`);
5457
}
5558

5659
// Execute "npm publish" to publish
57-
execSync(`npm publish --access public --tag ${tag}`)
60+
execSync(`npm publish --access public --tag ${tag}`);

tools/scripts/start-local-registry.ts

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@
22
* This script starts a local registry for e2e testing purposes.
33
* It is meant to be called in jest's globalSetup.
44
*/
5-
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry'
6-
import { execFileSync } from 'child_process'
5+
import { startLocalRegistry } from '@nx/js/plugins/jest/local-registry';
6+
import { execFileSync } from 'child_process';
77

88
export default async () => {
99
// local registry target to run
10-
const localRegistryTarget = '@create-solana-game/source:local-registry'
10+
const localRegistryTarget = '@create-solana-game/source:local-registry';
1111
// storage folder for the local registry
12-
const storage = './tmp/local-registry/storage'
12+
const storage = './tmp/local-registry/storage';
1313

1414
global.stopLocalRegistry = await startLocalRegistry({
1515
localRegistryTarget,
1616
storage,
1717
verbose: false,
18-
})
19-
const nx = require.resolve('nx')
20-
execFileSync(nx, ['run-many', '--targets', 'publish', '--ver', '1.0.0', '--tag', 'e2e'], {
21-
env: process.env,
22-
stdio: 'inherit',
23-
})
24-
}
18+
});
19+
const nx = require.resolve('nx');
20+
execFileSync(
21+
nx,
22+
['run-many', '--targets', 'publish', '--ver', '99.0.0', '--tag', 'e2e'],
23+
{
24+
env: process.env,
25+
stdio: 'inherit',
26+
}
27+
);
28+
};

0 commit comments

Comments
 (0)