Skip to content
This repository was archived by the owner on Nov 26, 2024. It is now read-only.

Commit 6670fa5

Browse files
Adding more missing files and settings from module-template
1 parent cb1a715 commit 6670fa5

File tree

9 files changed

+571
-56
lines changed

9 files changed

+571
-56
lines changed

.depcheckrc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"ignores": [
3+
"@lavamoat/allow-scripts",
4+
"@lavamoat/preinstall-always-fail",
5+
"@metamask/auto-changelog",
6+
"@types/*",
7+
"prettier-plugin-packagejson",
8+
"ts-node"
9+
]
10+
}

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
* text=auto
22

33
yarn.lock linguist-generated=false
4+
5+
# yarn v3
6+
# See: https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored
7+
/.yarn/releases/** binary
8+
/.yarn/plugins/** binary

.vscode/settings.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

.yarnrc.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ nodeLinker: node-modules
1010

1111
plugins:
1212
- path: .yarn/plugins/@yarnpkg/plugin-allow-scripts.cjs
13-
spec: "https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js"
13+
spec: 'https://raw.githubusercontent.com/LavaMoat/LavaMoat/main/packages/yarn-plugin-allow-scripts/bundles/@yarnpkg/plugin-allow-scripts.js'
1414
- path: .yarn/plugins/@yarnpkg/plugin-constraints.cjs
15-
spec: "@yarnpkg/plugin-constraints"
15+
spec: '@yarnpkg/plugin-constraints'
1616

1717
yarnPath: .yarn/releases/yarn-3.2.1.cjs

constraints.pro

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
%===============================================================================
2+
% Utility predicates
3+
%===============================================================================
4+
5+
% True if RepoName can be unified with the repository name part of RepoUrl, a
6+
% complete URL for a repository on GitHub. This URL must include the ".git"
7+
% extension.
8+
repo_name(RepoUrl, RepoName) :-
9+
Prefix = 'https://github.com/MetaMask/',
10+
atom_length(Prefix, PrefixLength),
11+
Suffix = '.git',
12+
atom_length(Suffix, SuffixLength),
13+
atom_length(RepoUrl, RepoUrlLength),
14+
sub_atom(RepoUrl, 0, PrefixLength, After, Prefix),
15+
sub_atom(RepoUrl, Before, SuffixLength, 0, Suffix),
16+
Start is RepoUrlLength - After + 1,
17+
End is Before + 1,
18+
RepoNameLength is End - Start,
19+
sub_atom(RepoUrl, PrefixLength, RepoNameLength, SuffixLength, RepoName).
20+
21+
%===============================================================================
22+
% Constraints
23+
%===============================================================================
24+
25+
% The package must have a name.
26+
\+ gen_enforced_field(WorkspaceCwd, 'name', null).
27+
28+
% The package must have a description.
29+
\+ gen_enforced_field(WorkspaceCwd, 'description', null).
30+
% The description cannot end with a period.
31+
gen_enforced_field(WorkspaceCwd, 'description', DescriptionWithoutTrailingPeriod) :-
32+
workspace_field(WorkspaceCwd, 'description', Description),
33+
atom_length(Description, Length),
34+
LengthLessOne is Length - 1,
35+
sub_atom(Description, LengthLessOne, 1, 0, LastCharacter),
36+
sub_atom(Description, 0, LengthLessOne, 1, DescriptionWithoutPossibleTrailingPeriod),
37+
(
38+
LastCharacter == '.' ->
39+
DescriptionWithoutTrailingPeriod = DescriptionWithoutPossibleTrailingPeriod ;
40+
DescriptionWithoutTrailingPeriod = Description
41+
).
42+
43+
% The homepage of the package must match its name (which is in turn based on its
44+
% workspace directory name).
45+
gen_enforced_field(WorkspaceCwd, 'homepage', CorrectHomepageUrl) :-
46+
workspace_field(WorkspaceCwd, 'repository.url', RepoUrl),
47+
repo_name(RepoUrl, RepoName),
48+
atomic_list_concat(['https://github.com/MetaMask/', RepoName, '#readme'], CorrectHomepageUrl).
49+
50+
% The bugs URL of the package must point to the Issues page for the repository.
51+
gen_enforced_field(WorkspaceCwd, 'bugs.url', CorrectBugsUrl) :-
52+
\+ workspace_field(WorkspaceCwd, 'private', true),
53+
workspace_field(WorkspaceCwd, 'repository.url', RepoUrl),
54+
repo_name(RepoUrl, RepoName),
55+
atomic_list_concat(['https://github.com/MetaMask/', RepoName, '/issues'], CorrectBugsUrl).
56+
57+
% The package must specify Git as the repository type.
58+
gen_enforced_field(WorkspaceCwd, 'repository.type', 'git').
59+
60+
% The package must match the URL of a repo within the MetaMask organization.
61+
gen_enforced_field(WorkspaceCwd, 'repository.url', 'https://github.com/MetaMask/<insert repo name here>.git') :-
62+
workspace_field(WorkspaceCwd, 'repository.url', RepoUrl),
63+
\+ repo_name(RepoUrl, _).
64+
65+
% The license for the package must be specified.
66+
gen_enforced_field(WorkspaceCwd, 'license').
67+
68+
% The type definitions entrypoint the package must be `./dist/types/index.d.ts`.
69+
gen_enforced_field(WorkspaceCwd, 'types', './dist/types/index.d.ts').
70+
gen_enforced_field(WorkspaceCwd, 'exports["."].types', './dist/types/index.d.ts').
71+
72+
% The entrypoint for the package must be `./dist/index.js`.
73+
gen_enforced_field(WorkspaceCwd, 'main', './dist/index.js').
74+
gen_enforced_field(WorkspaceCwd, 'exports["."].require', './dist/index.js').
75+
76+
% The module entrypoint for the package must be `./dist/index.mjs`.
77+
gen_enforced_field(WorkspaceCwd, 'module', './dist/index.mjs').
78+
gen_enforced_field(WorkspaceCwd, 'exports["."].import', './dist/index.mjs').
79+
80+
gen_enforced_field(WorkspaceCwd, 'exports["./package.json"]', './package.json').
81+
82+
% The list of files included in the package must only include files generated
83+
% during the build step.
84+
gen_enforced_field(WorkspaceCwd, 'files', ['dist']).
85+
86+
% If a dependency is listed under "dependencies", it should not be listed under
87+
% "devDependencies".
88+
gen_enforced_dependency(WorkspaceCwd, DependencyIdent, null, DependencyType) :-
89+
workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, 'dependencies'),
90+
workspace_has_dependency(WorkspaceCwd, DependencyIdent, DependencyRange, DependencyType),
91+
DependencyType == 'devDependencies'.
92+
93+
% The package must specify the expected node version constraint.
94+
gen_enforced_field(WorkspaceCwd, 'engines.node', '^18.18 || >=20').
95+
96+
% The package is public.
97+
gen_enforced_field(WorkspaceCwd, 'publishConfig.access', 'public').
98+
% The package is available on the NPM registry.
99+
gen_enforced_field(WorkspaceCwd, 'publishConfig.registry', 'https://registry.npmjs.org/').

jest.config.js

Lines changed: 183 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,48 @@
1+
/*
2+
* For a detailed explanation regarding each configuration property and type check, visit:
3+
* https://jestjs.io/docs/configuration
4+
*/
5+
16
module.exports = {
7+
// All imported modules in your tests should be mocked automatically
8+
// automock: false,
9+
10+
// Stop running tests after `n` failures
11+
// bail: 0,
12+
13+
// The directory where Jest should store its cached dependency information
14+
// cacheDirectory: "/private/var/folders/fk/c3y07g0576j8_2s9m01pk4qw0000gn/T/jest_dx",
15+
16+
// Automatically clear mock calls, instances and results before every test.
17+
// This does not remove any mock implementation that may have been provided,
18+
// so we disable it.
19+
// clearMocks: true,
20+
21+
// Indicates whether the coverage information should be collected while executing the test
222
collectCoverage: true,
3-
// Ensures that we collect coverage from all source files, not just tested
4-
// ones.
23+
24+
// An array of glob patterns indicating a set of files for which coverage information should be collected
525
collectCoverageFrom: [
626
'./src/**/*.ts',
727
'!./src/**/*index.ts',
828
'!./src/js/colors/colors.ts',
929
],
10-
coverageReporters: ['text', 'html'],
30+
31+
// The directory where Jest should output its coverage files
32+
coverageDirectory: 'coverage',
33+
34+
// An array of regexp pattern strings used to skip coverage collection
35+
// coveragePathIgnorePatterns: [
36+
// "/node_modules/"
37+
// ],
38+
39+
// Indicates which provider should be used to instrument code for coverage
40+
coverageProvider: 'babel',
41+
42+
// A list of reporter names that Jest uses when writing coverage reports
43+
coverageReporters: ['html', 'json-summary', 'text'],
44+
45+
// An object that configures minimum threshold enforcement for coverage results
1146
coverageThreshold: {
1247
global: {
1348
branches: 100,
@@ -16,16 +51,158 @@ module.exports = {
1651
statements: 100,
1752
},
1853
},
19-
moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'],
54+
55+
// A path to a custom dependency extractor
56+
// dependencyExtractor: undefined,
57+
58+
// Make calling deprecated APIs throw helpful error messages
59+
// errorOnDeprecated: false,
60+
61+
// Force coverage collection from ignored files using an array of glob patterns
62+
// forceCoverageMatch: [],
63+
64+
// A path to a module which exports an async function that is triggered once before all test suites
65+
// globalSetup: undefined,
66+
67+
// A path to a module which exports an async function that is triggered once after all test suites
68+
// globalTeardown: undefined,
69+
70+
// A set of global variables that need to be available in all test environments
71+
// globals: {},
72+
73+
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
74+
// maxWorkers: "50%",
75+
76+
// An array of directory names to be searched recursively up from the requiring module's location
77+
// moduleDirectories: [
78+
// "node_modules"
79+
// ],
80+
81+
// An array of file extensions your modules use
82+
// moduleFileExtensions: [
83+
// "js",
84+
// "jsx",
85+
// "ts",
86+
// "tsx",
87+
// "json",
88+
// "node"
89+
// ],
90+
91+
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
92+
// moduleNameMapper: {},
93+
94+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
95+
// modulePathIgnorePatterns: [],
96+
97+
// Activates notifications for test results
98+
// notify: false,
99+
100+
// An enum that specifies notification mode. Requires { notify: true }
101+
// notifyMode: "failure-change",
102+
103+
// A preset that is used as a base for Jest's configuration
20104
preset: 'ts-jest',
105+
106+
// Run tests from one or more projects
107+
// projects: undefined,
108+
109+
// Use this configuration option to add custom reporters to Jest
110+
// reporters: undefined,
111+
21112
// "resetMocks" resets all mocks, including mocked modules, to jest.fn(),
22113
// between each test case.
23114
resetMocks: true,
115+
116+
// Reset the module registry before running each individual test
117+
// resetModules: false,
118+
119+
// A path to a custom resolver
120+
// resolver: undefined,
121+
24122
// "restoreMocks" restores all mocks created using jest.spyOn to their
25123
// original implementations, between each test. It does not affect mocked
26124
// modules.
27125
restoreMocks: true,
28-
testEnvironment: 'node',
29-
testRegex: ['\\.test\\.(ts|js)$'],
126+
127+
// The root directory that Jest should scan for tests and modules within
128+
// rootDir: undefined,
129+
130+
// A list of paths to directories that Jest should use to search for files in
131+
// roots: [
132+
// "<rootDir>"
133+
// ],
134+
135+
// Allows you to use a custom runner instead of Jest's default test runner
136+
// runner: "jest-runner",
137+
138+
// The paths to modules that run some code to configure or set up the testing environment before each test
139+
// setupFiles: [],
140+
141+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
142+
// setupFilesAfterEnv: [],
143+
144+
// The number of seconds after which a test is considered as slow and reported as such in the results.
145+
// slowTestThreshold: 5,
146+
147+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
148+
// snapshotSerializers: [],
149+
150+
// The test environment that will be used for testing
151+
// testEnvironment: "jest-environment-node",
152+
153+
// Options that will be passed to the testEnvironment
154+
// testEnvironmentOptions: {},
155+
156+
// Adds a location field to test results
157+
// testLocationInResults: false,
158+
159+
// The glob patterns Jest uses to detect test files
160+
// testMatch: [
161+
// "**/__tests__/**/*.[jt]s?(x)",
162+
// "**/?(*.)+(spec|test).[tj]s?(x)"
163+
// ],
164+
165+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
166+
// testPathIgnorePatterns: [
167+
// "/node_modules/"
168+
// ],
169+
170+
// The regexp pattern or array of patterns that Jest uses to detect test files
171+
// testRegex: [],
172+
173+
// This option allows the use of a custom results processor
174+
// testResultsProcessor: undefined,
175+
176+
// This option allows use of a custom test runner
177+
// testRunner: "jest-circus/runner",
178+
179+
// Reduce the default test timeout from 5s to 2.5s
30180
testTimeout: 2500,
181+
182+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
183+
// testURL: "http://localhost",
184+
185+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
186+
// timers: "real",
187+
188+
// A map from regular expressions to paths to transformers
189+
// transform: undefined,
190+
191+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
192+
// transformIgnorePatterns: [
193+
// "/node_modules/",
194+
// "\\.pnp\\.[^\\/]+$"
195+
// ],
196+
197+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
198+
// unmockedModulePathPatterns: undefined,
199+
200+
// Indicates whether each individual test should be reported during the run
201+
// verbose: undefined,
202+
203+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
204+
// watchPathIgnorePatterns: [],
205+
206+
// Whether to use watchman for file crawling
207+
// watchman: true,
31208
};

scripts/get.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
if [[ ${RUNNER_DEBUG:-0} == 1 ]]; then
8+
set -x
9+
fi
10+
11+
KEY="${1}"
12+
OUTPUT="${2}"
13+
14+
if [[ -z $KEY ]]; then
15+
echo "Error: KEY not specified."
16+
exit 1
17+
fi
18+
19+
if [[ -z $OUTPUT ]]; then
20+
echo "Error: OUTPUT not specified."
21+
exit 1
22+
fi
23+
24+
echo "$OUTPUT=$(jq --raw-output "$KEY" package.json)" >> "$GITHUB_OUTPUT"

scripts/prepack.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -o pipefail
5+
6+
if [[ -n $SKIP_PREPACK ]]; then
7+
echo "Notice: skipping prepack."
8+
exit 0
9+
fi
10+
11+
yarn build

0 commit comments

Comments
 (0)