@w5s/mrm-preset 1.0.0-alpha.3 → 1.0.0-alpha.6

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/CHANGELOG.md CHANGED
@@ -3,6 +3,62 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.6](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.5...@w5s/mrm-preset@1.0.0-alpha.6) (2022-02-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * correct gitignore task ([b4f0903](https://github.com/w5s/project-config/commit/b4f0903561c97500aef65488ef06ccd7eae0db80))
12
+ * remove jest on lint-staged ([2fbc851](https://github.com/w5s/project-config/commit/2fbc85132ab380429d6966bff47b176bcfb51f6d))
13
+ * shorten eslint extensions ([aecc870](https://github.com/w5s/project-config/commit/aecc870ce0b288436208757376bc05504bff3331))
14
+
15
+
16
+ ### Features
17
+
18
+ * use es-jest as default jest preset ([61535d9](https://github.com/w5s/project-config/commit/61535d9c47c25150becc564a5dd273d7cc14b579))
19
+
20
+
21
+
22
+
23
+
24
+ # [1.0.0-alpha.5](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.4...@w5s/mrm-preset@1.0.0-alpha.5) (2022-02-18)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * change bootstrap behavior ([497c83a](https://github.com/w5s/project-config/commit/497c83a4082f7fd4e3b8b6913802ebcb21caa65a))
30
+ * remove lint-staged + cspell integration ([6747c83](https://github.com/w5s/project-config/commit/6747c83ec997034d25d136bc5aa008ed108ceb96))
31
+ * use UNLICENSED for default license ([608ee8f](https://github.com/w5s/project-config/commit/608ee8f0bf57fec94636587b116d5bda0fb4ee3f))
32
+
33
+
34
+ ### Features
35
+
36
+ * add gitignore for yarn v2 ([06c547a](https://github.com/w5s/project-config/commit/06c547a6b7813f935678c29b410aee62da5b3866))
37
+ * add support for yarn berry ([2b77669](https://github.com/w5s/project-config/commit/2b77669a29316825a38470c80a48aff8ab068f7f))
38
+
39
+
40
+
41
+
42
+
43
+ # [1.0.0-alpha.4](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.3...@w5s/mrm-preset@1.0.0-alpha.4) (2022-02-16)
44
+
45
+
46
+ ### Bug Fixes
47
+
48
+ * correct eslint vscode settings ([a32e0fb](https://github.com/w5s/project-config/commit/a32e0fb739cbe349565b26ea412cdf37e3d56bdb))
49
+ * correct mrm preset url ([ad6f030](https://github.com/w5s/project-config/commit/ad6f03091e0a294c043974b564e24c79023e659b))
50
+ * correct typo ([2218859](https://github.com/w5s/project-config/commit/221885997fec37149f7e349b00a58fbcb3bfb8db))
51
+ * rollback to eslint.validate vscode setting ([769a2e1](https://github.com/w5s/project-config/commit/769a2e100083aca4f5e9037fa539fcf1f6002d65))
52
+
53
+
54
+ ### Features
55
+
56
+ * improve typescript eslint configuration ([efc6f1c](https://github.com/w5s/project-config/commit/efc6f1cef876e8fc5d4d1d1b94ca90a6805fbbbf))
57
+
58
+
59
+
60
+
61
+
6
62
  # [1.0.0-alpha.3](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.2...@w5s/mrm-preset@1.0.0-alpha.3) (2022-02-15)
7
63
 
8
64
 
@@ -1,8 +1,11 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix */
2
2
  const path = require('path');
3
- const { packageJson, file } = require('mrm-core');
3
+ const { packageJson, file, yaml } = require('mrm-core');
4
+ // @ts-ignore
5
+ const execCommand = require('mrm-core/src/util/execCommand');
4
6
  const npm = require('../core/npm');
5
7
  const pkg = require('../core/pkg');
8
+ const { gitIgnoreTemplate } = require('../core/git');
6
9
 
7
10
  /**
8
11
  * @param {{
@@ -14,56 +17,63 @@ const pkg = require('../core/pkg');
14
17
  * @returns {void}
15
18
  */
16
19
  function task({ mrmPreset, mrmTask, packageArchetype, packageManager }) {
20
+ const isYarn = file('package-lock.json').exists()
21
+ ? false
22
+ : file('yarn.lock').exists()
23
+ ? true
24
+ : packageManager === 'yarn';
25
+ const isYarnBerry = false;
17
26
  /**
18
27
  * setup package.json from following object
19
28
  */
20
29
 
21
- const packageFile = packageJson({
30
+ packageJson({
22
31
  name: path.basename(process.cwd()),
23
32
  version: '1.0.0-alpha.0',
24
33
  private: true,
25
- license: 'PRIVATE',
34
+ license: 'UNLICENSED',
26
35
  description: '',
27
- });
28
-
29
- packageFile.merge({
30
- scripts: {
31
- configure: `npm run mrm -- ${mrmTask}`,
32
- mrm: `mrm --preset ${mrmPreset}`,
33
- },
34
- });
35
- pkg.value(packageFile, {
36
- path: 'packageManager',
36
+ }).save();
37
+ gitIgnoreTemplate(['macOS', 'NodeJS', 'VisualStudioCode']);
38
+ if (isYarn && isYarnBerry) {
39
+ execCommand(undefined, 'yarn', ['set', 'version', 'berry']);
40
+ yaml('.yarnrc.yml').set('nodeLinker', 'node-modules').save();
41
+ execCommand(undefined, 'yarn', ['install']);
42
+ }
43
+ npm.dependency({
44
+ dev: true,
45
+ name: ['mrm', mrmPreset],
46
+ yarn: isYarn,
37
47
  state: 'present',
38
- update: packageManager,
39
- default: () => {
40
- if (file('yarn.lock').exists()) {
41
- return 'yarn';
42
- }
43
-
44
- // return 'npm';
45
- return undefined;
46
- },
47
48
  });
48
- pkg.value(packageFile, {
49
- path: 'mrmConfig.packageArchetype',
50
- state: 'present',
51
- update: packageArchetype,
52
- default: () => {
53
- if (file('lerna.json').exists() || Boolean(packageFile.get('workspaces'))) {
54
- return 'workspace';
55
- }
56
49
 
57
- return 'library';
58
- },
50
+ pkg.withPackageJson((packageFile) => {
51
+ // Add MRM default scripts
52
+ pkg.script(packageFile, {
53
+ name: 'configure',
54
+ state: 'default',
55
+ script: `${packageManager} run mrm -- ${mrmTask}`,
56
+ });
57
+ pkg.script(packageFile, {
58
+ name: 'mrm',
59
+ state: 'default',
60
+ script: `${packageManager} --preset ${mrmPreset}`,
61
+ });
59
62
  });
60
- packageFile.save();
61
63
 
62
- npm.dependency({
63
- dev: true,
64
- name: ['mrm', mrmPreset],
65
- yarn: packageManager === 'yarn',
66
- state: 'present',
64
+ pkg.withPackageJson((packageFile) => {
65
+ pkg.value(packageFile, {
66
+ path: 'mrmConfig.packageArchetype',
67
+ state: 'present',
68
+ update: packageArchetype,
69
+ default: () => {
70
+ if (file('lerna.json').exists() || Boolean(packageFile.get('workspaces'))) {
71
+ return 'workspace';
72
+ }
73
+
74
+ return 'library';
75
+ },
76
+ });
67
77
  });
68
78
  }
69
79
 
@@ -6,7 +6,7 @@
6
6
  We as members, contributors, and leaders pledge to make participation in our
7
7
  community a harassment-free experience for everyone, regardless of age, body
8
8
  size, visible or invisible disability, ethnicity, sex characteristics, gender
9
- identity and expression, level of experience, education, socio-economic status,
9
+ identity and expression, level of experience, education, socioeconomic status,
10
10
  nationality, personal appearance, race, caste, color, religion, or sexual identity
11
11
  and orientation.
12
12
 
@@ -119,11 +119,11 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
119
119
  version 2.0, available at
120
120
  [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
121
121
 
122
- Community Impact Guidelines were inspired by
122
+ Community Impact Guidelines were inspired by
123
123
  [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
124
124
 
125
125
  For answers to common questions about this code of conduct, see the FAQ at
126
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
126
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available
127
127
  at [https://www.contributor-covenant.org/translations][translations].
128
128
 
129
129
  [homepage]: https://www.contributor-covenant.org
@@ -131,4 +131,3 @@ at [https://www.contributor-covenant.org/translations][translations].
131
131
  [Mozilla CoC]: https://github.com/mozilla/diversity
132
132
  [FAQ]: https://www.contributor-covenant.org/faq
133
133
  [translations]: https://www.contributor-covenant.org/translations
134
-
@@ -11,6 +11,7 @@ module.exports = {
11
11
  yarn-debug.log*
12
12
  yarn-error.log*
13
13
  lerna-debug.log*
14
+ .pnpm-debug.log*
14
15
 
15
16
  # Diagnostic reports (https://nodejs.org/api/report.html)
16
17
  report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -47,8 +48,8 @@ module.exports = {
47
48
  node_modules/
48
49
  jspm_packages/
49
50
 
50
- # TypeScript v1 declaration files
51
- typings/
51
+ # Snowpack dependency directory (https://snowpack.dev/)
52
+ web_modules/
52
53
 
53
54
  # TypeScript cache
54
55
  *.tsbuildinfo
@@ -59,6 +60,9 @@ module.exports = {
59
60
  # Optional eslint cache
60
61
  .eslintcache
61
62
 
63
+ # Optional stylelint cache
64
+ .stylelintcache
65
+
62
66
  # Microbundle cache
63
67
  .rpt2_cache/
64
68
  .rts2_cache_cjs/
@@ -74,15 +78,20 @@ module.exports = {
74
78
  # Yarn Integrity file
75
79
  .yarn-integrity
76
80
 
77
- # dotenv environment variables file
81
+ # dotenv environment variable files
78
82
  .env
79
- .env.test
83
+ .env.development.local
84
+ .env.test.local
85
+ .env.production.local
86
+ .env.local
80
87
 
81
88
  # parcel-bundler cache (https://parceljs.org/)
82
89
  .cache
90
+ .parcel-cache
83
91
 
84
92
  # Next.js build output
85
93
  .next
94
+ out
86
95
 
87
96
  # Nuxt.js build / generate output
88
97
  .nuxt
@@ -92,11 +101,18 @@ module.exports = {
92
101
  .cache/
93
102
  # Comment in the public line in if your project uses Gatsby and not Next.js
94
103
  # https://nextjs.org/blog/next-9-1#public-directory-support
95
- public/
104
+ # public
96
105
 
97
106
  # vuepress build output
98
107
  .vuepress/dist
99
108
 
109
+ # vuepress v2.x temp and cache directory
110
+ .temp
111
+ .cache
112
+
113
+ # Docusaurus cache and generated files
114
+ .docusaurus
115
+
100
116
  # Serverless directories
101
117
  .serverless/
102
118
 
@@ -107,7 +123,17 @@ module.exports = {
107
123
  .dynamodb/
108
124
 
109
125
  # TernJS port file
110
- .tern-port`,
126
+ .tern-port
127
+
128
+ # Stores VSCode versions used for testing VSCode extensions
129
+ .vscode-test
130
+
131
+ # yarn v2
132
+ .yarn/cache
133
+ .yarn/unplugged
134
+ .yarn/build-state.yml
135
+ .yarn/install-state.gz
136
+ .pnp.*`,
111
137
  VisualStudioCode: `
112
138
  .vscode/*
113
139
  !.vscode/settings.json
package/core/git.js CHANGED
@@ -61,3 +61,20 @@ function gitIgnore(section, sectionContent) {
61
61
  });
62
62
  }
63
63
  exports.gitIgnore = gitIgnore;
64
+
65
+ /**
66
+ * @param {string[]} flags
67
+ */
68
+ function gitIgnoreTemplate(flags) {
69
+ // eslint-disable-next-line global-require, import/no-dynamic-require
70
+ const templateMap = require('./git.ignore');
71
+
72
+ flags.forEach((flag) => {
73
+ // @ts-ignore
74
+ if (templateMap[flag]) {
75
+ // @ts-ignore
76
+ gitIgnore(flag, templateMap[flag]);
77
+ }
78
+ });
79
+ }
80
+ exports.gitIgnoreTemplate = gitIgnoreTemplate;
package/core/githooks.js CHANGED
@@ -44,7 +44,8 @@ function husky({ state }) {
44
44
  * }} options
45
45
  */
46
46
  function gitHook({ name, state, content }) {
47
- const hasHusky = Boolean(packageJson().get('devDependencies.husky'));
47
+ const packageFileDefault = packageJson();
48
+ const hasHusky = pkg.hasDependency(packageFileDefault, 'husky', 'dev');
48
49
  const hasGitHook = hasHusky && state === 'present';
49
50
  const hookDirectory = '.husky';
50
51
  const hookFileName = path.join(hookDirectory, name);
package/core/jest.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable no-template-curly-in-string */
2
2
  const { packageJson } = require('mrm-core');
3
- const { vscodeSnippets } = require('./vscode');
4
3
  const pkg = require('./pkg');
5
4
  const npm = require('./npm');
6
5
  const project = require('./project');
@@ -13,34 +12,31 @@ const project = require('./project');
13
12
  function jest({ state }) {
14
13
  const packageFileDefault = packageJson();
15
14
  const hasJest = state === 'present';
16
- const hasTypescript = Boolean(packageFileDefault.get('devDependencies.typescript'));
17
- const hasWorkspaces = Boolean(packageFileDefault.get('workspaces'));
15
+ const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
16
+ const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
18
17
 
19
18
  pkg.withPackageJson((packageFile) => {
20
19
  if (hasJest) {
21
- const ignorePatterns = ['/node_modules/', '/docs/', '/lib/', '/build/', '/.cache/', '/public/'];
22
- packageFile.merge({
23
- jest: {
24
- coveragePathIgnorePatterns: ignorePatterns,
25
- testPathIgnorePatterns: ignorePatterns,
26
- },
27
- });
28
- if (hasTypescript) {
20
+ if (hasWorkspaces) {
21
+ pkg.value(packageFile, {
22
+ path: 'jest',
23
+ state: 'present',
24
+ update: () => ({
25
+ preset: 'es-jest',
26
+ projects: packageFile
27
+ .get('workspaces.packages', packageFile.get('workspaces', []))
28
+ .map((/** @type {string} */ workspace) => `<rootDir>/${workspace}`),
29
+ }),
30
+ });
31
+ } else {
32
+ const ignorePatterns = ['/node_modules/', '/docs/', '/lib/', '/build/', '/.cache/', '/public/'];
29
33
  packageFile.merge({
30
34
  jest: {
31
- globals: {
32
- 'ts-jest': {
33
- tsconfig: hasWorkspaces ? 'tsconfig.settings.json' : 'tsconfig.json',
34
- },
35
- },
36
- roots: hasWorkspaces ? ['<rootDir>/packages'] : null,
37
- transform: {
38
- '^.+\\.tsx?$': 'ts-jest',
39
- },
35
+ preset: 'es-jest',
36
+ coveragePathIgnorePatterns: ignorePatterns,
37
+ testPathIgnorePatterns: ignorePatterns,
40
38
  },
41
39
  });
42
- } else {
43
- packageFile.unset('jest.globals.ts-jest').unset('jest.transform.^.+\\.tsx?$');
44
40
  }
45
41
  } else {
46
42
  packageFile.unset('jest');
@@ -56,48 +52,43 @@ function jest({ state }) {
56
52
  script: hasWorkspaces ? pkg.emptyScript : 'jest',
57
53
  state: !hasJest || hasWorkspaces ? 'default' : 'present',
58
54
  });
59
- pkg.script(packageFile, {
60
- name: `${project.test}:watch`,
61
- script: pkg.emptyScript,
62
- state: 'absent',
63
- });
64
55
  });
65
56
  // Dependencies
66
57
  npm.dependency({
67
58
  dev: true,
68
- name: ['jest', 'babel-jest', '@babel/core'],
59
+ name: ['jest', 'es-jest'],
69
60
  state: hasJest ? 'present' : 'absent',
70
61
  });
71
62
  npm.dependency({
72
63
  dev: true,
73
- name: ['ts-jest', '@types/jest'],
64
+ name: ['@types/jest'],
74
65
  state: hasJest && hasTypescript ? 'present' : 'absent',
75
66
  });
76
67
 
77
- vscodeSnippets({
78
- name: 'jest',
79
- snippets: {
80
- 'Jest Describe Block': {
81
- body: ["describe('${1:description}', () => {", '\t$0', '});'],
82
- description: 'Jest describe block',
83
- prefix: 'describe',
84
- scope: 'javascript,typescript',
85
- },
86
- 'Jest Expect': {
87
- body: 'expect($0)',
88
- description: 'Jest expect assertion',
89
- prefix: 'expect',
90
- scope: 'javascript,typescript',
91
- },
92
- 'Jest Test Block': {
93
- body: ["test('${1:description}', () => {", '\t$0', '});'],
94
- description: 'Jest test block',
95
- prefix: 'test',
96
- scope: 'javascript,typescript',
97
- },
98
- },
99
- state: hasJest ? 'present' : 'absent',
100
- });
68
+ // vscodeSnippets({
69
+ // name: 'jest',
70
+ // snippets: {
71
+ // 'Jest Describe Block': {
72
+ // body: ["describe('${1:description}', () => {", '\t$0', '});'],
73
+ // description: 'Jest describe block',
74
+ // prefix: 'describe',
75
+ // scope: 'javascript,typescript',
76
+ // },
77
+ // 'Jest Expect': {
78
+ // body: 'expect($0)',
79
+ // description: 'Jest expect assertion',
80
+ // prefix: 'expect',
81
+ // scope: 'javascript,typescript',
82
+ // },
83
+ // 'Jest Test Block': {
84
+ // body: ["test('${1:description}', () => {", '\t$0', '});'],
85
+ // description: 'Jest test block',
86
+ // prefix: 'test',
87
+ // scope: 'javascript,typescript',
88
+ // },
89
+ // },
90
+ // state: hasJest ? 'present' : 'absent',
91
+ // });
101
92
  }
102
93
 
103
94
  module.exports = {
package/core/npm.js CHANGED
@@ -134,7 +134,7 @@ function runNpm(deps, options = {}, exec) {
134
134
  function runYarn(deps, options = {}, exec) {
135
135
  const add = options.dev ? ['add', '--dev'] : ['add'];
136
136
  const remove = ['remove'];
137
- const args = (options.remove ? remove : add).concat(isUsingWorkspaces() ? ['-W'] : []).concat(deps);
137
+ const args = (options.remove ? remove : add).concat(isUsingWorkspaces() && !isYarnBerry() ? ['-W'] : []).concat(deps);
138
138
 
139
139
  return execCommand(exec, 'yarn', args, {
140
140
  cwd: options.cwd,
@@ -248,6 +248,10 @@ function isUsingWorkspaces() {
248
248
  return Boolean(packageJson().get('workspaces'));
249
249
  }
250
250
 
251
+ function isYarnBerry() {
252
+ return fs.existsSync('.yarnrc.yml');
253
+ }
254
+
251
255
  /**
252
256
  * @param {{
253
257
  * name: string|string[]|Record<string, string>,
package/core/pkg.js CHANGED
@@ -58,6 +58,34 @@ function manager(packageFile) {
58
58
  return defaultManager;
59
59
  }
60
60
 
61
+ /**
62
+ *
63
+ * @param {import('mrm-core').PackageJson} packageFile
64
+ */
65
+ function hasWorkspaces(packageFile) {
66
+ return Boolean(packageFile.get('workspaces'));
67
+ }
68
+
69
+ /**
70
+ *
71
+ * @param {import('mrm-core').PackageJson} packageFile
72
+ * @param {string} packageName
73
+ * @param {'normal'|'dev'|'peer'=} dependencyType
74
+ */
75
+ function hasDependency(packageFile, packageName, dependencyType) {
76
+ return Boolean(
77
+ packageFile.get(
78
+ `${
79
+ dependencyType == null || dependencyType === 'normal'
80
+ ? 'dependencies'
81
+ : dependencyType === 'dev'
82
+ ? 'devDependencies'
83
+ : 'peerDependencies'
84
+ }.${packageName}`
85
+ )
86
+ );
87
+ }
88
+
61
89
  /**
62
90
  *
63
91
  * @param {import('mrm-core').PackageJson} packageFile
@@ -94,5 +122,7 @@ module.exports = {
94
122
  script,
95
123
  manager,
96
124
  engineMinVersion,
125
+ hasDependency,
126
+ hasWorkspaces,
97
127
  withPackageJson,
98
128
  };
@@ -34,7 +34,7 @@ function semanticRelease({ state, update, preset }) {
34
34
  });
35
35
  });
36
36
  }
37
- semanticRelease.command = function () {
37
+ semanticRelease.command = function command() {
38
38
  return 'semantic-release';
39
39
  };
40
40
 
package/core/typedoc.js CHANGED
@@ -23,7 +23,7 @@ const jsonFile = require('./jsonFile');
23
23
  */
24
24
  function typedoc({ state, update }) {
25
25
  const packageFileDefault = packageJson();
26
- const hasWorkspaces = Boolean(packageFileDefault.get('workspaces'));
26
+ const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
27
27
  const hasTypedoc = state === 'present';
28
28
 
29
29
  pkg.withPackageJson((packageFile) => {
package/cspell/index.js CHANGED
@@ -1,9 +1,6 @@
1
1
  const { cspell } = require('../core/cspell');
2
- const { lintStaged } = require('../core/lintStaged');
3
- const { hasGit } = require('../core/git');
4
2
 
5
3
  function task() {
6
- const gitSupported = hasGit();
7
4
  cspell({
8
5
  state: 'present',
9
6
  update: (_) => ({
@@ -23,14 +20,6 @@ function task() {
23
20
  ),
24
21
  }),
25
22
  });
26
-
27
- lintStaged({
28
- state: gitSupported ? 'present' : 'absent',
29
- update: (config) => ({
30
- ...config,
31
- '*.*': ['cspell --no-must-find-files'],
32
- }),
33
- });
34
23
  }
35
24
 
36
25
  task.description = 'Adds CSpell support';
package/eslint/index.js CHANGED
@@ -15,7 +15,8 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
15
15
  * }} config
16
16
  */
17
17
  function task({ eslintPreset, eslintRules }) {
18
- const hasTypescript = packageJson().get('devDependencies.typescript');
18
+ const packageFileDefault = packageJson();
19
+ const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
19
20
  const hasJSX = true;
20
21
  const hasJSON = true;
21
22
 
@@ -69,7 +70,7 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
69
70
  json: hasJSON,
70
71
  };
71
72
  const extList = Object.keys(extsMap).filter((ext) => extsMap[ext]);
72
- const extOption = ` --ext ${extList.map((ext) => `.${ext}`).join(',')}`;
73
+ const extOption = ` --ext=${extList.join(',')}`;
73
74
 
74
75
  pkg.withPackageJson((packageFile) => {
75
76
  pkg.script(packageFile, {
package/githooks/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const path = require('path');
2
2
  const { packageJson, template } = require('mrm-core');
3
3
  const project = require('../core/project');
4
+ const pkg = require('../core/pkg');
4
5
  const { hasGit } = require('../core/git');
5
6
  const { gitHook, husky } = require('../core/githooks');
6
7
  const { lintStaged } = require('../core/lintStaged');
@@ -10,9 +11,8 @@ function createGitHooks() {
10
11
  function task() {
11
12
  const gitSupported = hasGit();
12
13
  const packageFile = packageJson();
13
- const hasESLint = Boolean(packageFile.get('devDependencies.eslint'));
14
- const hasJest = Boolean(packageFile.get('devDependencies.jest'));
15
- const hasTsc = Boolean(packageFile.get('devDependencies.typescript'));
14
+ const hasESLint = pkg.hasDependency(packageFile, 'eslint', 'dev');
15
+ const hasTsc = pkg.hasDependency(packageFile, 'typescript', 'dev');
16
16
 
17
17
  husky({
18
18
  state: gitSupported ? 'present' : 'absent',
@@ -22,16 +22,8 @@ function createGitHooks() {
22
22
  update: (config) => ({
23
23
  ...config,
24
24
  '*.json': [...(hasESLint ? ['eslint'] : [])],
25
- '*.js?(x)': [
26
- ...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []),
27
- ...(hasESLint ? ['eslint'] : []),
28
- ...(hasJest ? ['jest --ci --bail --findRelatedTests'] : []),
29
- ],
30
- '*.ts?(x)': [
31
- ...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []),
32
- ...(hasESLint ? ['eslint'] : []),
33
- ...(hasJest ? ['jest --ci --bail --findRelatedTests'] : []),
34
- ],
25
+ '*.js?(x)': [...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []), ...(hasESLint ? ['eslint'] : [])],
26
+ '*.ts?(x)': [...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []), ...(hasESLint ? ['eslint'] : [])],
35
27
  }),
36
28
  });
37
29
  gitHook({
@@ -1,25 +1,8 @@
1
- const { gitIgnore } = require('../core/git');
1
+ const { gitIgnoreTemplate } = require('../core/git');
2
2
 
3
- /**
4
- *
5
- * @param {string} templatePath
6
- * @param {Array<string>} flags
7
- */
8
- function createGitIgnore(templatePath, flags) {
9
- function task() {
10
- // eslint-disable-next-line global-require, import/no-dynamic-require
11
- const templateMap = require(templatePath);
12
-
13
- flags.forEach((flag) => {
14
- if (templateMap[flag]) {
15
- gitIgnore(flag, templateMap[flag]);
16
- }
17
- });
18
- }
19
-
20
- task.description = 'Adds Gitignore file';
21
-
22
- return task;
3
+ function task() {
4
+ gitIgnoreTemplate(['macOS', 'NodeJS', 'VisualStudioCode']);
23
5
  }
6
+ task.description = 'Adds Gitignore file';
24
7
 
25
- module.exports = createGitIgnore(require.resolve('./template'), ['macOS', 'NodeJS', 'VisualStudioCode']);
8
+ module.exports = task;
package/lang/index.js CHANGED
@@ -4,7 +4,6 @@ const npm = require('../core/npm');
4
4
  const { gitIgnore } = require('../core/git');
5
5
  const project = require('../core/project');
6
6
  const { eslintIgnore } = require('../core/eslint');
7
- const { useWorkspaces } = require('../core/workspace');
8
7
  const { typedoc } = require('../core/typedoc');
9
8
  const pkg = require('../core/pkg');
10
9
 
@@ -27,8 +26,9 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
27
26
  }
28
27
  task.typescript = () => {
29
28
  const tsConfigPreset = tsConfigDefault;
30
- const isApplication = packageJson().get('mrmConfig.packageArchetype') === 'application';
31
- const hasWorkspaces = useWorkspaces();
29
+ const packageFile = packageJson();
30
+ const isApplication = packageFile.get('mrmConfig.packageArchetype') === 'application';
31
+ const hasWorkspaces = pkg.hasWorkspaces(packageFile);
32
32
  const tsConfigSettingsName = 'tsconfig.settings.json';
33
33
  const tsConfigSettings = json(tsConfigSettingsName);
34
34
  const tsConfig = json('tsconfig.json');
@@ -77,9 +77,9 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
77
77
  }
78
78
  }
79
79
  // Application setup
80
- pkg.withPackageJson((packageFile) => {
80
+ pkg.withPackageJson((_packageFile) => {
81
81
  if (isApplication) {
82
- pkg.script(packageFile, {
82
+ pkg.script(_packageFile, {
83
83
  name: project.develop,
84
84
  script:
85
85
  "NODE_ENV=development ts-node-dev --require='tsconfig-paths/register' -r dotenv/config -- ./src/index.ts dotenv_config_path=.env",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/mrm-preset",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.6",
4
4
  "description": "Mrm configuration presets",
5
5
  "keywords": [
6
6
  "mrm",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "9935d3a478d08c3c6c02f467f65c623a16749753"
48
+ "gitHead": "0bf05f35388f1ddb53438a017186cf64d2ce99f2"
49
49
  }
package/renovate/index.js CHANGED
@@ -54,6 +54,6 @@ function createRenovate({ renovatePresetApplication, renovatePresetLibrary }) {
54
54
  }
55
55
 
56
56
  module.exports = createRenovate({
57
- renovatePresetApplication: '@w5s/renovate-config:application',
58
- renovatePresetLibrary: '@w5s/renovate-config:library',
57
+ renovatePresetApplication: 'github>w5s/renovate-config:application',
58
+ renovatePresetLibrary: 'github>w5s/renovate-config:library',
59
59
  });
package/core/workspace.js DELETED
@@ -1,6 +0,0 @@
1
- const { packageJson } = require('mrm-core');
2
-
3
- function useWorkspaces() {
4
- return packageJson().get('mrmConfig.packageArchetype') === 'workspace';
5
- }
6
- exports.useWorkspaces = useWorkspaces;