@dword-design/base 9.0.1 → 9.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__snapshots__/index.spec.js.snap +77 -0
- package/dist/cli.js +72 -74
- package/dist/commands/check-unknown-files/common-allowed-matches.js +1 -0
- package/dist/commands/check-unknown-files/index.js +21 -0
- package/dist/commands/check-unknown-files/unknown-files-error.js +18 -0
- package/dist/commands/commit/index.js +4 -0
- package/dist/commands/depcheck.js +27 -0
- package/dist/commands/lint/index.js +22 -0
- package/dist/{__snapshots__/prepare.spec.js.snap → commands/prepare/__snapshots__/index.spec.js.snap} +2 -2
- package/dist/commands/prepare/index.js +18 -0
- package/dist/commands/test/index.js +3 -0
- package/dist/commands/test-docker/index.js +35 -0
- package/dist/{test → commands/test-raw}/__snapshots__/index.spec.js.snap +0 -0
- package/dist/commands/test-raw/index.js +49 -0
- package/dist/commands/test-raw/is-ci.js +9 -0
- package/dist/get-depcheck-special-base/index.js +5 -0
- package/dist/{generated-files → get-generated-files}/__snapshots__/index.spec.js.snap +0 -0
- package/dist/get-generated-files/babel.js +4 -0
- package/dist/get-generated-files/commitizen.js +4 -0
- package/dist/get-generated-files/commitlint.js +8 -0
- package/dist/get-generated-files/common-editor-ignore.js +1 -0
- package/dist/get-generated-files/common-gitignore.js +1 -0
- package/dist/get-generated-files/editorconfig.js +16 -0
- package/dist/{generated-files/common-editor-ignore.json → get-generated-files/get-editor-ignore/__snapshots__/index.spec.js.snap} +9 -3
- package/dist/get-generated-files/get-editor-ignore/index.js +7 -0
- package/dist/get-generated-files/get-eslint/index.js +6 -0
- package/dist/{generated-files/__snapshots__/github-sync-metadata.spec.js.snap → get-generated-files/get-github-sync-metadata/__snapshots__/index.spec.js.snap} +2 -3
- package/dist/get-generated-files/get-github-sync-metadata/index.js +31 -0
- package/dist/{generated-files/github-workflow → get-generated-files/get-github-workflow}/__snapshots__/index.spec.js.snap +0 -0
- package/dist/get-generated-files/get-github-workflow/index.js +14 -0
- package/dist/get-generated-files/get-github-workflow/steps/cancel-existing.js +6 -0
- package/dist/get-generated-files/get-github-workflow/steps/check-unknown-files.js +3 -0
- package/dist/get-generated-files/get-github-workflow/steps/coverage.js +6 -0
- package/dist/get-generated-files/get-github-workflow/steps/get-release.js +33 -0
- package/dist/get-generated-files/get-github-workflow/steps/get-test.js +37 -0
- package/dist/{generated-files/github-workflow → get-generated-files/get-github-workflow}/strategies/job-matrix.js +12 -21
- package/dist/get-generated-files/get-github-workflow/strategies/simple.js +30 -0
- package/dist/get-generated-files/get-gitignore/__snapshots__/index.spec.js.snap +14 -0
- package/dist/get-generated-files/get-gitignore/index.js +7 -0
- package/dist/get-generated-files/get-gitpod-dockerfile.js +29 -0
- package/dist/get-generated-files/get-license-string.js +22 -0
- package/dist/get-generated-files/get-package-config/index.js +39 -0
- package/dist/{generated-files/readme-string → get-generated-files/get-readme-string}/__snapshots__/index.spec.js.snap +0 -0
- package/dist/get-generated-files/get-readme-string/index.js +30 -0
- package/dist/get-generated-files/get-readme-string/replacements.js +139 -0
- package/dist/get-generated-files/get-release/index.js +12 -0
- package/dist/{generated-files/__snapshots__/renovate.spec.js.snap → get-generated-files/get-renovate/__snapshots__/index.spec.js.snap} +4 -4
- package/dist/get-generated-files/get-renovate/index.js +22 -0
- package/dist/get-generated-files/get-vscode/__snapshots__/index.spec.js.snap +33 -0
- package/dist/get-generated-files/get-vscode/index.js +11 -0
- package/dist/get-generated-files/gitattributes.js +9 -0
- package/dist/{generated-files/__snapshots__/github-deprecated-dependencies.spec.js.snap → get-generated-files/github-deprecated-dependencies/__snapshots__/index.spec.js.snap} +1 -1
- package/dist/{generated-files/github-deprecated-dependencies.js → get-generated-files/github-deprecated-dependencies/index.js} +2 -10
- package/dist/get-generated-files/github-deprecated-dependencies-issue-template.js +15 -0
- package/dist/get-generated-files/github-funding.js +5 -0
- package/dist/get-generated-files/github-labels.js +17 -0
- package/dist/{generated-files → get-generated-files}/github-sync-labels.js +2 -10
- package/dist/get-generated-files/gitpod.js +13 -0
- package/dist/get-generated-files/index.js +73 -0
- package/dist/get-git-info/index.js +18 -0
- package/dist/index.js +109 -45
- package/dist/load-config/index.js +15 -0
- package/package.json +7 -8
- package/dist/check-unknown-files/common-allowed-matches.json +0 -18
- package/dist/check-unknown-files/index.js +0 -34
- package/dist/check-unknown-files/unknown-files-error.js +0 -26
- package/dist/commit.js +0 -13
- package/dist/config.js +0 -64
- package/dist/depcheck-special-base-config.js +0 -15
- package/dist/generated-files/babel.js +0 -13
- package/dist/generated-files/commitizen.js +0 -13
- package/dist/generated-files/commitlint.js +0 -17
- package/dist/generated-files/common-gitignore.json +0 -8
- package/dist/generated-files/editor-ignore.js +0 -15
- package/dist/generated-files/editorconfig.js +0 -25
- package/dist/generated-files/eslint.js +0 -14
- package/dist/generated-files/gitattributes.js +0 -18
- package/dist/generated-files/github-deprecated-dependencies-issue-template.js +0 -24
- package/dist/generated-files/github-funding.js +0 -13
- package/dist/generated-files/github-labels.js +0 -26
- package/dist/generated-files/github-sync-metadata.js +0 -39
- package/dist/generated-files/github-workflow/index.js +0 -22
- package/dist/generated-files/github-workflow/steps/cancel-existing.js +0 -14
- package/dist/generated-files/github-workflow/steps/check-unknown-files.js +0 -11
- package/dist/generated-files/github-workflow/steps/coverage.js +0 -14
- package/dist/generated-files/github-workflow/steps/release.js +0 -37
- package/dist/generated-files/github-workflow/steps/test.js +0 -44
- package/dist/generated-files/github-workflow/strategies/simple.js +0 -39
- package/dist/generated-files/gitignore.js +0 -15
- package/dist/generated-files/gitpod-dockerfile.js +0 -37
- package/dist/generated-files/gitpod.js +0 -23
- package/dist/generated-files/index.js +0 -90
- package/dist/generated-files/license-string.js +0 -30
- package/dist/generated-files/package-config.js +0 -49
- package/dist/generated-files/readme-string/index.js +0 -38
- package/dist/generated-files/readme-string/replacements.js +0 -144
- package/dist/generated-files/release.js +0 -20
- package/dist/generated-files/renovate.js +0 -31
- package/dist/generated-files/vscode.js +0 -19
- package/dist/git-info.js +0 -19
- package/dist/lint.js +0 -32
- package/dist/package-config.js +0 -11
- package/dist/prepare.js +0 -26
- package/dist/raw-config.js +0 -26
- package/dist/test/depcheck.js +0 -38
- package/dist/test/index.js +0 -65
- package/dist/test-docker.js +0 -44
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`index empty parent 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"allowedMatches": Array [],
|
|
6
|
+
"commands": Object {},
|
|
7
|
+
"coverageFileExtensions": Array [],
|
|
8
|
+
"deployAssets": Array [],
|
|
9
|
+
"deployEnv": Object {},
|
|
10
|
+
"deployPlugins": Array [],
|
|
11
|
+
"editorIgnore": Array [],
|
|
12
|
+
"git": undefined,
|
|
13
|
+
"gitignore": Array [],
|
|
14
|
+
"name": "base-config-foo",
|
|
15
|
+
"nodeVersion": 16,
|
|
16
|
+
"preDeploySteps": Array [],
|
|
17
|
+
"readmeInstallString": "## Install
|
|
18
|
+
|
|
19
|
+
\`\`\`bash
|
|
20
|
+
# npm
|
|
21
|
+
$ npm install foo
|
|
22
|
+
|
|
23
|
+
# Yarn
|
|
24
|
+
$ yarn add foo
|
|
25
|
+
\`\`\`",
|
|
26
|
+
"seeAlso": Array [],
|
|
27
|
+
"supportedNodeVersions": Array [
|
|
28
|
+
14,
|
|
29
|
+
16,
|
|
30
|
+
18,
|
|
31
|
+
],
|
|
32
|
+
"syncKeywords": true,
|
|
33
|
+
}
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
exports[`index inherited 1`] = `
|
|
37
|
+
Object {
|
|
38
|
+
"allowedMatches": Array [],
|
|
39
|
+
"coverageFileExtensions": Array [],
|
|
40
|
+
"deployAssets": Array [
|
|
41
|
+
Object {
|
|
42
|
+
"label": "Foo",
|
|
43
|
+
"path": "foo.js",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
"deployEnv": Object {
|
|
47
|
+
"FOO": "\${{ secrets.FOO }}",
|
|
48
|
+
},
|
|
49
|
+
"deployPlugins": Array [
|
|
50
|
+
"semantic-release-foo",
|
|
51
|
+
],
|
|
52
|
+
"editorIgnore": Array [
|
|
53
|
+
"foo",
|
|
54
|
+
],
|
|
55
|
+
"git": undefined,
|
|
56
|
+
"gitignore": Array [
|
|
57
|
+
"foo",
|
|
58
|
+
],
|
|
59
|
+
"name": "base-config-foo",
|
|
60
|
+
"nodeVersion": 10,
|
|
61
|
+
"packageBaseConfig": Object {
|
|
62
|
+
"main": "dist/index.scss",
|
|
63
|
+
},
|
|
64
|
+
"preDeploySteps": Array [
|
|
65
|
+
Object {
|
|
66
|
+
"run": "foo",
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
"readmeInstallString": "foo",
|
|
70
|
+
"seeAlso": Array [],
|
|
71
|
+
"supportedNodeVersions": Array [
|
|
72
|
+
1,
|
|
73
|
+
2,
|
|
74
|
+
],
|
|
75
|
+
"syncKeywords": true,
|
|
76
|
+
}
|
|
77
|
+
`;
|
package/dist/cli.js
CHANGED
|
@@ -1,75 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}))(_checkUnknownFiles$co)), (0, _values.default)(_ref))
|
|
75
|
-
});
|
|
2
|
+
import mapValues from "@dword-design/functions/dist/map-values.js";
|
|
3
|
+
import values from "@dword-design/functions/dist/values.js";
|
|
4
|
+
import makeCli from 'make-cli';
|
|
5
|
+
import { Base } from "./index.js";
|
|
6
|
+
import loadConfig from "./load-config/index.js";
|
|
7
|
+
const run = async () => {
|
|
8
|
+
const config = await loadConfig();
|
|
9
|
+
const base = new Base(config);
|
|
10
|
+
try {
|
|
11
|
+
var _ref, _checkUnknownFiles$co, _config$commands;
|
|
12
|
+
await makeCli({
|
|
13
|
+
commands: (_ref = (_checkUnknownFiles$co = {
|
|
14
|
+
checkUnknownFiles: {
|
|
15
|
+
handler: () => base.checkUnknownFiles()
|
|
16
|
+
},
|
|
17
|
+
commit: {
|
|
18
|
+
handler: () => base.commit(),
|
|
19
|
+
options: [{
|
|
20
|
+
description: 'Allow empty commits',
|
|
21
|
+
name: '--allow-empty'
|
|
22
|
+
}]
|
|
23
|
+
},
|
|
24
|
+
lint: {
|
|
25
|
+
handler: () => base.lint()
|
|
26
|
+
},
|
|
27
|
+
prepare: {
|
|
28
|
+
handler: () => base.prepare()
|
|
29
|
+
},
|
|
30
|
+
...(config.testInContainer && {
|
|
31
|
+
'test:raw': {
|
|
32
|
+
arguments: '[pattern]',
|
|
33
|
+
handler: (pattern, options) => base.testRaw({
|
|
34
|
+
pattern,
|
|
35
|
+
...options
|
|
36
|
+
}),
|
|
37
|
+
options: [{
|
|
38
|
+
description: 'Only run tests matching this string or regexp',
|
|
39
|
+
name: '-g, --grep <grep>'
|
|
40
|
+
}, {
|
|
41
|
+
description: 'Update snapshots',
|
|
42
|
+
name: '-u, --update-snapshots'
|
|
43
|
+
}]
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
test: {
|
|
47
|
+
arguments: '[pattern]',
|
|
48
|
+
handler: (pattern, options) => base.test({
|
|
49
|
+
pattern,
|
|
50
|
+
...options
|
|
51
|
+
}),
|
|
52
|
+
options: [{
|
|
53
|
+
description: 'Only run tests matching this string or regexp',
|
|
54
|
+
name: '-g, --grep <grep>'
|
|
55
|
+
}, {
|
|
56
|
+
description: 'Update snapshots',
|
|
57
|
+
name: '-u, --update-snapshots'
|
|
58
|
+
}]
|
|
59
|
+
},
|
|
60
|
+
...(_config$commands = config.commands, mapValues(command => typeof command === 'function' ? {
|
|
61
|
+
handler: command
|
|
62
|
+
} : command)(_config$commands))
|
|
63
|
+
}, mapValues((command, name) => ({
|
|
64
|
+
name,
|
|
65
|
+
...command
|
|
66
|
+
}))(_checkUnknownFiles$co)), values(_ref))
|
|
67
|
+
});
|
|
68
|
+
} catch (error) {
|
|
69
|
+
console.log(error.message);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
run();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default ['__image_snapshots__', '__snapshots__', '.baserc.json', '.env.schema.json', '.eslintrc.json', '.git', '.husky/_', '.husky/commit-msg', '.husky/post-checkout', '.husky/post-commit', '.husky/pre-push', '.husky/post-merge', 'CHANGELOG.md', 'doc', 'types.d.ts', 'yarn.lock'];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import filter from "@dword-design/functions/dist/filter.js";
|
|
2
|
+
import fromPairs from "@dword-design/functions/dist/from-pairs.js";
|
|
3
|
+
import keys from "@dword-design/functions/dist/keys.js";
|
|
4
|
+
import map from "@dword-design/functions/dist/map.js";
|
|
5
|
+
import globby from 'globby';
|
|
6
|
+
import ignore from 'ignore';
|
|
7
|
+
import commonAllowedMatches from "./common-allowed-matches.js";
|
|
8
|
+
import UnknownFilesError from "./unknown-files-error.js";
|
|
9
|
+
export default async function () {
|
|
10
|
+
var _this$generatedFiles, _ref, _globby;
|
|
11
|
+
const allowedMatches = [...(_this$generatedFiles = this.generatedFiles, keys(_this$generatedFiles)), ...commonAllowedMatches, ...this.config.allowedMatches];
|
|
12
|
+
const unknownFiles = (_ref = (_globby = globby('**', {
|
|
13
|
+
dot: true,
|
|
14
|
+
gitignore: true,
|
|
15
|
+
ignore: allowedMatches
|
|
16
|
+
}), await _globby), filter(ignore().add(this.getGitignoreConfig()).createFilter())(_ref));
|
|
17
|
+
if (unknownFiles.length > 0) {
|
|
18
|
+
var _ref2, _unknownFiles;
|
|
19
|
+
throw new UnknownFilesError((_ref2 = (_unknownFiles = unknownFiles, map(file => [file, true])(_unknownFiles)), fromPairs(_ref2)));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import endent from "@dword-design/functions/dist/endent.js";
|
|
2
|
+
import identity from "@dword-design/functions/dist/identity.js";
|
|
3
|
+
import join from "@dword-design/functions/dist/join.js";
|
|
4
|
+
import keys from "@dword-design/functions/dist/keys.js";
|
|
5
|
+
import map from "@dword-design/functions/dist/map.js";
|
|
6
|
+
import sortBy from "@dword-design/functions/dist/sort-by.js";
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
const packageConfig = fs.readJsonSync(new URL('../../../package.json', import.meta.url));
|
|
9
|
+
export default class extends Error {
|
|
10
|
+
constructor(files) {
|
|
11
|
+
var _ref, _ref2, _ref3, _files;
|
|
12
|
+
super(endent`
|
|
13
|
+
There are files in this repository that are not known to ${packageConfig.name}. Let's discuss about them in a PR!
|
|
14
|
+
|
|
15
|
+
${(_ref = (_ref2 = (_ref3 = (_files = files, keys(_files)), map(file => `* ${file}`)(_ref3)), sortBy(identity)(_ref2)), join('\n')(_ref))}
|
|
16
|
+
`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import join from "@dword-design/functions/dist/join.js";
|
|
2
|
+
import map from "@dword-design/functions/dist/map.js";
|
|
3
|
+
import omit from "@dword-design/functions/dist/omit.js";
|
|
4
|
+
import depcheck from 'depcheck';
|
|
5
|
+
const processResult = (caption, deps) => {
|
|
6
|
+
if (deps.length > 0) {
|
|
7
|
+
var _ref, _deps;
|
|
8
|
+
throw new Error((_ref = [caption, ...(_deps = deps, map(dep => `* ${dep}`)(_deps))], join('\n')(_ref)));
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
export default async function () {
|
|
12
|
+
var _this$packageConfig, _this$packageConfig2;
|
|
13
|
+
let result = await depcheck('.', {
|
|
14
|
+
package: (_this$packageConfig = this.packageConfig, omit(['devDependencies'])(_this$packageConfig)),
|
|
15
|
+
skipMissing: true,
|
|
16
|
+
...this.config.depcheckConfig,
|
|
17
|
+
ignorePatterns: ['*.spec.js', 'package.json']
|
|
18
|
+
});
|
|
19
|
+
processResult('Unused dependencies', result.dependencies);
|
|
20
|
+
result = await depcheck('.', {
|
|
21
|
+
package: (_this$packageConfig2 = this.packageConfig, omit(['dependencies'])(_this$packageConfig2)),
|
|
22
|
+
skipMissing: true,
|
|
23
|
+
...this.config.depcheckConfig,
|
|
24
|
+
ignorePatterns: ['!*.spec.js']
|
|
25
|
+
});
|
|
26
|
+
processResult('Unused devDependencies', result.devDependencies);
|
|
27
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import execa from 'execa';
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import parsePackagejsonName from 'parse-packagejson-name';
|
|
4
|
+
const require = createRequire(import.meta.url);
|
|
5
|
+
export default async function (options) {
|
|
6
|
+
const packageName = parsePackagejsonName(this.packageConfig.name).fullName;
|
|
7
|
+
if (this.config.git !== undefined && packageName !== this.config.git.project) {
|
|
8
|
+
throw new Error(`Package name '${packageName}' has to be equal to repository name '${this.config.git.project}'`);
|
|
9
|
+
}
|
|
10
|
+
options = {
|
|
11
|
+
resolvePluginsRelativeTo: require.resolve('@dword-design/eslint-config'),
|
|
12
|
+
...options
|
|
13
|
+
};
|
|
14
|
+
try {
|
|
15
|
+
await execa('eslint', ['--fix', '--ext', '.js,.json,.vue', '--ignore-path', '.gitignore', '--resolve-plugins-relative-to', options.resolvePluginsRelativeTo, '.'], {
|
|
16
|
+
all: true
|
|
17
|
+
});
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw new Error(error.all);
|
|
20
|
+
}
|
|
21
|
+
await this.config.lint();
|
|
22
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`index valid 1`] = `
|
|
4
4
|
Object {
|
|
5
5
|
".babelrc.json": true,
|
|
6
6
|
".commitlintrc.json": true,
|
|
@@ -29,7 +29,7 @@ Object {
|
|
|
29
29
|
}
|
|
30
30
|
`;
|
|
31
31
|
|
|
32
|
-
exports[`
|
|
32
|
+
exports[`index valid 2`] = `
|
|
33
33
|
"<!-- TITLE/ -->
|
|
34
34
|
# foo
|
|
35
35
|
<!-- /TITLE -->
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import first from "@dword-design/functions/dist/first.js";
|
|
2
|
+
import keys from "@dword-design/functions/dist/keys.js";
|
|
3
|
+
import packageName from 'depcheck-package-name';
|
|
4
|
+
import execa from 'execa';
|
|
5
|
+
import fs from 'fs-extra';
|
|
6
|
+
import { createRequire } from 'module';
|
|
7
|
+
import outputFiles from 'output-files';
|
|
8
|
+
const _require = createRequire(import.meta.url);
|
|
9
|
+
const commitlintPackageConfig = _require(packageName`@commitlint/cli/package.json`);
|
|
10
|
+
export default async function () {
|
|
11
|
+
await outputFiles(this.generatedFiles);
|
|
12
|
+
if (await fs.exists('.git')) {
|
|
13
|
+
var _ref, _commitlintPackageCon;
|
|
14
|
+
await execa.command('husky install');
|
|
15
|
+
await execa('husky', ['set', '.husky/commit-msg', `npx ${(_ref = (_commitlintPackageCon = commitlintPackageConfig.bin, keys(_commitlintPackageCon)), first(_ref))} --edit "$1"`]);
|
|
16
|
+
}
|
|
17
|
+
await this.config.prepare();
|
|
18
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import filter from "@dword-design/functions/dist/filter.js";
|
|
2
|
+
import flatMap from "@dword-design/functions/dist/flat-map.js";
|
|
3
|
+
import join from "@dword-design/functions/dist/join.js";
|
|
4
|
+
import keys from "@dword-design/functions/dist/keys.js";
|
|
5
|
+
import map from "@dword-design/functions/dist/map.js";
|
|
6
|
+
import replace from "@dword-design/functions/dist/replace.js";
|
|
7
|
+
import { constantCase } from 'constant-case';
|
|
8
|
+
import execa from 'execa';
|
|
9
|
+
import findUp from 'find-up';
|
|
10
|
+
import fs from 'fs-extra';
|
|
11
|
+
import os from 'os';
|
|
12
|
+
export default async function (options) {
|
|
13
|
+
var _ref, _this$packageConfig$n, _ref2, _ref3;
|
|
14
|
+
options = {
|
|
15
|
+
log: true,
|
|
16
|
+
...options
|
|
17
|
+
};
|
|
18
|
+
const volumeName = (_ref = (_this$packageConfig$n = this.packageConfig.name, replace('@', '')(_this$packageConfig$n)), replace('/', '-')(_ref));
|
|
19
|
+
const envSchemaPath = findUp.sync('.env.schema.json');
|
|
20
|
+
const envVariableNames = (_ref2 = (_ref3 = envSchemaPath ? await fs.readJson(envSchemaPath) : {}, keys(_ref3)), map(name => {
|
|
21
|
+
var _name;
|
|
22
|
+
return `TEST_${(_name = name, constantCase(_name))}`;
|
|
23
|
+
})(_ref2));
|
|
24
|
+
const userInfo = os.userInfo();
|
|
25
|
+
try {
|
|
26
|
+
var _ref4, _envVariableNames, _ref5;
|
|
27
|
+
return await execa('docker', ['run', '--rm', '--tty', ...(_ref4 = (_envVariableNames = envVariableNames, filter(name => process.env[name] !== undefined)(_envVariableNames)), flatMap(name => ['--env', `${name}=${process.env[name]}`])(_ref4)), '-v', `${process.cwd()}:/app`, '-v', `${volumeName}:/app/node_modules`, 'dworddesign/testing:latest', 'bash', '-c', (_ref5 = ['yarn --frozen-lockfile', '&&', 'yarn test:raw', ...(options.updateSnapshots ? [' --update-snapshots'] : []), ...(options.pattern ? [`"${options.pattern}"`] : []), ...(options.grep ? [`-g "${options.grep}"`] : [])], join(' ')(_ref5))], options.log ? {
|
|
28
|
+
stdio: 'inherit'
|
|
29
|
+
} : {
|
|
30
|
+
all: true
|
|
31
|
+
});
|
|
32
|
+
} finally {
|
|
33
|
+
await execa('docker', ['run', '--rm', '--tty', '-v', `${process.cwd()}:/app`, '-v', `${volumeName}:/app/node_modules`, 'dworddesign/testing:latest', 'bash', '-c', `chown -R ${userInfo.uid}:${userInfo.gid} /app`]);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import endent from "@dword-design/functions/dist/endent.js";
|
|
2
|
+
import flatMap from "@dword-design/functions/dist/flat-map.js";
|
|
3
|
+
import includes from "@dword-design/functions/dist/includes.js";
|
|
4
|
+
import packageJsonSchema from '@dword-design/package-json-schema';
|
|
5
|
+
import Ajv from 'ajv';
|
|
6
|
+
import packageName from 'depcheck-package-name';
|
|
7
|
+
import execa from 'execa';
|
|
8
|
+
import { createRequire } from 'module';
|
|
9
|
+
import stdEnv from 'std-env';
|
|
10
|
+
import isCI from "./is-ci.js";
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const ajv = new Ajv({
|
|
13
|
+
allowUnionTypes: true
|
|
14
|
+
});
|
|
15
|
+
const validatePackageJson = ajv.compile(packageJsonSchema);
|
|
16
|
+
export default async function (options) {
|
|
17
|
+
var _ref, _this$config$coverage;
|
|
18
|
+
options = {
|
|
19
|
+
log: !stdEnv.test,
|
|
20
|
+
...options
|
|
21
|
+
};
|
|
22
|
+
if (!options.pattern) {
|
|
23
|
+
if (!validatePackageJson(this.packageConfig)) {
|
|
24
|
+
throw new Error(endent`
|
|
25
|
+
package.json invalid
|
|
26
|
+
${ajv.errorsText(validatePackageJson.errors)}
|
|
27
|
+
`);
|
|
28
|
+
}
|
|
29
|
+
await this.lint();
|
|
30
|
+
await this.depcheck();
|
|
31
|
+
}
|
|
32
|
+
const runDockerTests = !isCI() || !(_ref = ['win32', 'darwin'], includes(process.platform)(_ref));
|
|
33
|
+
return execa(this.packageConfig.type === 'module' ? packageName`c8` : packageName`nyc`, ['--reporter', 'lcov', '--reporter', 'text', '--cwd', process.cwd(), '--all', ...(_this$config$coverage = this.config.coverageFileExtensions, flatMap(extension => ['--extension', extension])(_this$config$coverage)), '--exclude', '**/*.spec.js', '--exclude', 'coverage', '--exclude', 'tmp-*', '--exclude', 'dist', 'mocha', '--ui', packageName`mocha-ui-exports-auto-describe`, '--require', packageName`@dword-design/babel-register`, '--require', packageName`@dword-design/pretest`, '--file', require.resolve('@dword-design/setup-test'), ...(runDockerTests ? [] : ['--ignore', '**/*.usesdocker.spec.js']), '--timeout', 130000, ...(options.grep ? ['--grep', options.grep] : []), ...(process.platform === 'win32' ? ['--exit'] : []), options.pattern || '{,!(node_modules)/**/}*.spec.js'], {
|
|
34
|
+
env: {
|
|
35
|
+
NODE_ENV: 'test',
|
|
36
|
+
...(this.packageConfig.type === 'module' && {
|
|
37
|
+
NODE_OPTIONS: `--experimental-loader=${packageName`@dword-design/babel-register-esm`}`
|
|
38
|
+
}),
|
|
39
|
+
...(options.updateSnapshots && {
|
|
40
|
+
SNAPSHOT_UPDATE: 1
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
...(options.log ? {
|
|
44
|
+
stdio: 'inherit'
|
|
45
|
+
} : {
|
|
46
|
+
all: true
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default ['.babelrc.json', '.commitlintrc.json', '.cz.json', '.editorconfig', '.eslintrc.json', '.gitattributes', '.github', '.gitignore', '.gitpod.Dockerfile', '.gitpod.yml', '.husky', '.nyc_output', '.releaserc.json', '.renovaterc.json', 'CHANGELOG.md', 'coverage', 'LICENSE.md', 'node_modules', 'yarn.lock'];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default ['.DS_Store', '/.env.json', '/.test.env.json', '/.nyc_output', '/coverage', '/node_modules'];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import endent from "@dword-design/functions/dist/endent.js";
|
|
2
|
+
export default endent`
|
|
3
|
+
# Editor configuration, see http://editorconfig.org
|
|
4
|
+
root = true
|
|
5
|
+
|
|
6
|
+
[*]
|
|
7
|
+
charset = utf-8
|
|
8
|
+
indent_style = space
|
|
9
|
+
indent_size = 2
|
|
10
|
+
insert_final_newline = true
|
|
11
|
+
trim_trailing_whitespace = true
|
|
12
|
+
|
|
13
|
+
[*.md]
|
|
14
|
+
max_line_length = off
|
|
15
|
+
trim_trailing_whitespace = false
|
|
16
|
+
`;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`index valid 1`] = `
|
|
4
|
+
Array [
|
|
2
5
|
".babelrc.json",
|
|
3
6
|
".commitlintrc.json",
|
|
4
7
|
".cz.json",
|
|
@@ -14,8 +17,11 @@
|
|
|
14
17
|
".releaserc.json",
|
|
15
18
|
".renovaterc.json",
|
|
16
19
|
"CHANGELOG.md",
|
|
17
|
-
"coverage",
|
|
18
20
|
"LICENSE.md",
|
|
21
|
+
"coverage",
|
|
22
|
+
"dist",
|
|
23
|
+
"foo",
|
|
19
24
|
"node_modules",
|
|
20
|
-
"yarn.lock"
|
|
25
|
+
"yarn.lock",
|
|
21
26
|
]
|
|
27
|
+
`;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import identity from "@dword-design/functions/dist/identity.js";
|
|
2
|
+
import sortBy from "@dword-design/functions/dist/sort-by.js";
|
|
3
|
+
import commonEditorIgnore from "../common-editor-ignore.js";
|
|
4
|
+
export default function () {
|
|
5
|
+
var _ref;
|
|
6
|
+
return _ref = [...commonEditorIgnore, ...this.config.editorIgnore], sortBy(identity)(_ref);
|
|
7
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`index do not sync keywords 1`] = `
|
|
4
4
|
Object {
|
|
5
5
|
"jobs": Object {
|
|
6
6
|
"build": Object {
|
|
@@ -36,7 +36,7 @@ Object {
|
|
|
36
36
|
}
|
|
37
37
|
`;
|
|
38
38
|
|
|
39
|
-
exports[`
|
|
39
|
+
exports[`index valid 1`] = `
|
|
40
40
|
Object {
|
|
41
41
|
"jobs": Object {
|
|
42
42
|
"build": Object {
|
|
@@ -51,7 +51,6 @@ Object {
|
|
|
51
51
|
"approve": false,
|
|
52
52
|
"commitMessage": "fix: write GitHub metadata to package.json [{changes}]",
|
|
53
53
|
"githubToken": "\${{ secrets.GITHUB_TOKEN }}",
|
|
54
|
-
"syncKeywords": false,
|
|
55
54
|
},
|
|
56
55
|
},
|
|
57
56
|
Object {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default function () {
|
|
2
|
+
return {
|
|
3
|
+
jobs: {
|
|
4
|
+
build: {
|
|
5
|
+
'runs-on': 'ubuntu-latest',
|
|
6
|
+
steps: [{
|
|
7
|
+
uses: 'actions/checkout@v3'
|
|
8
|
+
}, {
|
|
9
|
+
uses: 'jaid/action-sync-node-meta@v2.0.0',
|
|
10
|
+
with: {
|
|
11
|
+
approve: false,
|
|
12
|
+
...(!this.config.syncKeywords && {
|
|
13
|
+
syncKeywords: false
|
|
14
|
+
}),
|
|
15
|
+
commitMessage: 'fix: write GitHub metadata to package.json [{changes}]',
|
|
16
|
+
githubToken: '${{ secrets.GITHUB_TOKEN }}'
|
|
17
|
+
}
|
|
18
|
+
}, {
|
|
19
|
+
uses: 'gautamkrishnar/keepalive-workflow@v1'
|
|
20
|
+
}]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
name: 'sync-metadata',
|
|
24
|
+
on: {
|
|
25
|
+
schedule: [{
|
|
26
|
+
cron: '0 5 * * *'
|
|
27
|
+
}],
|
|
28
|
+
workflow_dispatch: {}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import jobMatrixStrategy from "./strategies/job-matrix.js";
|
|
2
|
+
import simpleStrategy from "./strategies/simple.js";
|
|
3
|
+
export default function () {
|
|
4
|
+
return {
|
|
5
|
+
jobs: (this.config.useJobMatrix && !this.config.testInContainer ? jobMatrixStrategy : simpleStrategy)(this.config),
|
|
6
|
+
name: 'build',
|
|
7
|
+
on: {
|
|
8
|
+
pull_request: {},
|
|
9
|
+
push: {
|
|
10
|
+
branches: ['master']
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|