@form8ion/project 22.0.0-beta.2 → 22.0.0-beta.21

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.
Files changed (55) hide show
  1. package/README.md +70 -26
  2. package/lib/index.js +207 -105
  3. package/lib/index.js.map +1 -1
  4. package/package.json +28 -29
  5. package/src/ci-provider/index.js +1 -0
  6. package/src/ci-provider/prompt.js +17 -0
  7. package/src/ci-provider/prompt.test.js +27 -0
  8. package/src/ci-provider/scaffolder.js +27 -0
  9. package/src/ci-provider/scaffolder.test.js +68 -0
  10. package/src/ci-provider/schema.js +4 -0
  11. package/src/ci-provider/schema.test.js +43 -0
  12. package/src/contributing/scaffolder.js +2 -2
  13. package/src/contributing/scaffolder.test.js +14 -2
  14. package/src/dependency-updater/prompt.js +14 -8
  15. package/src/dependency-updater/prompt.test.js +16 -17
  16. package/src/dependency-updater/scaffolder.js +4 -2
  17. package/src/dependency-updater/scaffolder.test.js +18 -15
  18. package/src/editorconfig/index.js +1 -0
  19. package/src/editorconfig/scaffolder.js +1 -1
  20. package/src/editorconfig/tester.js +5 -0
  21. package/src/editorconfig/tester.test.js +25 -0
  22. package/src/index.js +1 -7
  23. package/src/language/prompt.js +14 -9
  24. package/src/language/prompt.test.js +15 -16
  25. package/src/language/scaffolder.js +4 -2
  26. package/src/language/scaffolder.test.js +13 -8
  27. package/src/license/lifter.js +1 -1
  28. package/src/license/scaffolder.js +2 -3
  29. package/src/license/scaffolder.test.js +5 -8
  30. package/src/license/tester.js +1 -1
  31. package/src/lift.js +8 -2
  32. package/src/lift.test.js +26 -13
  33. package/src/options-validator.js +3 -3
  34. package/src/options-validator.test.js +4 -6
  35. package/src/prompts/index.js +20 -0
  36. package/src/prompts/question-names.js +19 -5
  37. package/src/prompts/questions.js +7 -3
  38. package/src/prompts/questions.test.js +5 -6
  39. package/src/scaffolder.js +18 -17
  40. package/src/scaffolder.test.js +39 -31
  41. package/src/template-path.js +1 -1
  42. package/src/vcs/git/remotes.js +6 -7
  43. package/src/vcs/git/remotes.test.js +21 -16
  44. package/src/vcs/host/prompt.js +15 -10
  45. package/src/vcs/host/prompt.test.js +31 -25
  46. package/src/vcs/host/scaffolder.js +4 -2
  47. package/src/vcs/host/scaffolder.test.js +9 -7
  48. package/src/vcs/prompt.js +11 -9
  49. package/src/vcs/prompt.test.js +15 -12
  50. package/src/vcs/scaffolder.js +9 -11
  51. package/src/vcs/scaffolder.test.js +10 -9
  52. package/src/options-schemas.js +0 -3
  53. package/src/options-schemas.test.js +0 -20
  54. package/src/prompts/conditionals.js +0 -13
  55. package/src/prompts/conditionals.test.js +0 -51
@@ -16,7 +16,8 @@ vi.mock('./prompt.js');
16
16
 
17
17
  describe('vcs scaffolder', () => {
18
18
  const projectRoot = any.string();
19
- const decisions = any.simpleObject();
19
+ const prompt = () => undefined;
20
+ const logger = {info: () => {}};
20
21
 
21
22
  it('should scaffold the repository and vcs host details', async () => {
22
23
  const host = any.word();
@@ -29,14 +30,14 @@ describe('vcs scaffolder', () => {
29
30
  const vcsHostDetails = {host, owner, name};
30
31
  const sshUrl = any.url();
31
32
  const remoteOriginNextSteps = any.listOf(any.simpleObject);
32
- when(promptForRepoCreation).calledWith(decisions).thenResolve(true);
33
+ when(promptForRepoCreation).calledWith({prompt}).thenResolve(true);
33
34
  when(alreadyVersionedByGit).calledWith({projectRoot}).thenResolve(false);
34
35
  when(scaffoldVcsHost)
35
- .calledWith(vcsHosts, decisions, {projectName, projectRoot, description, visibility})
36
+ .calledWith(vcsHosts, {projectName, projectRoot, description, visibility}, {prompt})
36
37
  .thenResolve({vcs: {...vcsHostDetails, sshUrl, ...any.simpleObject()}});
37
- when(defineRemoteOrigin).calledWith(projectRoot, sshUrl).thenResolve({nextSteps: remoteOriginNextSteps});
38
+ when(defineRemoteOrigin).calledWith(projectRoot, sshUrl, {logger}).thenResolve({nextSteps: remoteOriginNextSteps});
38
39
 
39
- expect(await scaffoldVcs({projectRoot, projectName, decisions, vcsHosts, visibility, description})).toEqual({
40
+ expect(await scaffoldVcs({projectRoot, projectName, vcsHosts, visibility, description}, {prompt, logger})).toEqual({
40
41
  vcs: vcsHostDetails,
41
42
  nextSteps: [{summary: 'Commit scaffolded files'}, ...remoteOriginNextSteps]
42
43
  });
@@ -45,16 +46,16 @@ describe('vcs scaffolder', () => {
45
46
 
46
47
  it('should not scaffold a repository or vcs host details when the project is already versioned by git', async () => {
47
48
  const existingVcsDetails = any.simpleObject();
48
- when(promptForRepoCreation).calledWith(decisions).thenResolve(true);
49
+ when(promptForRepoCreation).calledWith({prompt}).thenResolve(true);
49
50
  when(alreadyVersionedByGit).calledWith({projectRoot}).thenResolve(true);
50
51
  when(determineExistingVcsDetails).calledWith({projectRoot}).thenResolve(existingVcsDetails);
51
52
 
52
- expect(await scaffoldVcs({projectRoot, decisions})).toEqual({vcs: existingVcsDetails});
53
+ expect(await scaffoldVcs({projectRoot}, {prompt, logger})).toEqual(existingVcsDetails);
53
54
  });
54
55
 
55
56
  it('should not scaffold a repository or vcs host details when a repository should not be created', async () => {
56
- when(promptForRepoCreation).calledWith(decisions).thenResolve(false);
57
+ when(promptForRepoCreation).calledWith({prompt}).thenResolve(false);
57
58
 
58
- expect(await scaffoldVcs({projectRoot, decisions})).toEqual({});
59
+ expect(await scaffoldVcs({projectRoot}, {prompt})).toEqual({});
59
60
  });
60
61
  });
@@ -1,3 +0,0 @@
1
- import joi from 'joi';
2
-
3
- export const decisionsSchema = joi.object();
@@ -1,20 +0,0 @@
1
- import {validateOptions} from '@form8ion/core';
2
-
3
- import {describe, expect, it} from 'vitest';
4
- import any from '@travi/any';
5
-
6
- import {decisionsSchema} from './options-schemas.js';
7
-
8
- describe('generic options schemas', () => {
9
- describe('decisions', () => {
10
- it('should return the validated options', () => {
11
- const options = any.simpleObject();
12
-
13
- expect(validateOptions(decisionsSchema, options)).toEqual(options);
14
- });
15
-
16
- it('should require the decisions to be defined as a map', () => {
17
- expect(() => validateOptions(decisionsSchema, any.word())).toThrowError('must be of type object');
18
- });
19
- });
20
- });
@@ -1,13 +0,0 @@
1
- import {questionNames} from './question-names.js';
2
-
3
- export function unlicensedConfirmationShouldBePresented(answers) {
4
- return 'Private' === answers[questionNames.VISIBILITY];
5
- }
6
-
7
- export function licenseChoicesShouldBePresented(answers) {
8
- return 'Public' === answers[questionNames.VISIBILITY] || !answers[questionNames.UNLICENSED];
9
- }
10
-
11
- export function copyrightInformationShouldBeRequested(answers) {
12
- return !!answers[questionNames.LICENSE];
13
- }
@@ -1,51 +0,0 @@
1
- import {describe, expect, it} from 'vitest';
2
- import any from '@travi/any';
3
-
4
- import {questionNames} from './question-names.js';
5
- import {
6
- copyrightInformationShouldBeRequested,
7
- licenseChoicesShouldBePresented,
8
- unlicensedConfirmationShouldBePresented
9
- } from './conditionals.js';
10
-
11
- describe('prompt conditionals', () => {
12
- describe('unlicensed confirmation', () => {
13
- it('should show the unlicensed confirmation for a private project', () => {
14
- expect(unlicensedConfirmationShouldBePresented({[questionNames.VISIBILITY]: 'Private'})).toBe(true);
15
- });
16
-
17
- it('should not show the unlicensed confirmation for a public project', () => {
18
- expect(unlicensedConfirmationShouldBePresented({[questionNames.VISIBILITY]: 'Public'})).toBe(false);
19
- });
20
- });
21
-
22
- describe('license choices', () => {
23
- it('should show the license choices for a public project', () => {
24
- expect(licenseChoicesShouldBePresented({[questionNames.VISIBILITY]: 'Public'})).toBe(true);
25
- });
26
-
27
- it('should show the license choices for a private project that is not unlicensed', () => {
28
- expect(licenseChoicesShouldBePresented({
29
- [questionNames.VISIBILITY]: 'Private',
30
- [questionNames.UNLICENSED]: false
31
- })).toBe(true);
32
- });
33
-
34
- it('should not show the license choices for a private project that is unlicensed', () => {
35
- expect(licenseChoicesShouldBePresented({
36
- [questionNames.VISIBILITY]: 'Private',
37
- [questionNames.UNLICENSED]: true
38
- })).toBe(false);
39
- });
40
- });
41
-
42
- describe('copyright', () => {
43
- it('should request the copyright information when the project is licensed', () => {
44
- expect(copyrightInformationShouldBeRequested({[questionNames.LICENSE]: any.string()})).toBe(true);
45
- });
46
-
47
- it('should not request the copyright information when the project is not licensed', () => {
48
- expect(copyrightInformationShouldBeRequested({[questionNames.LICENSE]: undefined})).toBe(false);
49
- });
50
- });
51
- });