@git.zone/cli 2.13.10 → 2.13.11

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 (102) hide show
  1. package/assets/templates/{npmextra/npmextra.json → smartconfig/_smartconfig.json} +3 -0
  2. package/dist_ts/classes.gitzoneconfig.js +4 -4
  3. package/dist_ts/gitzone.cli.js +1 -15
  4. package/dist_ts/mod_commit/index.js +4 -4
  5. package/dist_ts/mod_config/classes.commitconfig.d.ts +3 -3
  6. package/dist_ts/mod_config/classes.commitconfig.js +20 -20
  7. package/dist_ts/mod_config/classes.releaseconfig.d.ts +3 -3
  8. package/dist_ts/mod_config/classes.releaseconfig.js +21 -21
  9. package/dist_ts/mod_config/index.js +12 -12
  10. package/dist_ts/mod_format/classes.baseformatter.d.ts +2 -9
  11. package/dist_ts/mod_format/classes.baseformatter.js +13 -26
  12. package/dist_ts/mod_format/classes.formatplanner.d.ts +1 -3
  13. package/dist_ts/mod_format/classes.formatplanner.js +11 -39
  14. package/dist_ts/mod_format/classes.formatstats.d.ts +0 -5
  15. package/dist_ts/mod_format/classes.formatstats.js +3 -35
  16. package/dist_ts/mod_format/formatters/cleanup.formatter.js +1 -2
  17. package/dist_ts/mod_format/formatters/copy.formatter.js +5 -8
  18. package/dist_ts/mod_format/formatters/gitignore.formatter.d.ts +5 -0
  19. package/dist_ts/mod_format/formatters/gitignore.formatter.js +23 -29
  20. package/dist_ts/mod_format/formatters/packagejson.formatter.js +5 -5
  21. package/dist_ts/mod_format/formatters/prettier.formatter.js +4 -12
  22. package/dist_ts/mod_format/formatters/{npmextra.formatter.d.ts → smartconfig.formatter.d.ts} +6 -1
  23. package/dist_ts/mod_format/formatters/smartconfig.formatter.js +180 -0
  24. package/dist_ts/mod_format/formatters/templates.formatter.js +1 -10
  25. package/dist_ts/mod_format/formatters/tsconfig.formatter.js +6 -4
  26. package/dist_ts/mod_format/index.d.ts +0 -4
  27. package/dist_ts/mod_format/index.js +27 -78
  28. package/dist_ts/mod_format/interfaces.format.d.ts +1 -18
  29. package/dist_ts/mod_format/interfaces.format.js +16 -2
  30. package/dist_ts/mod_format/mod.plugins.d.ts +2 -7
  31. package/dist_ts/mod_format/mod.plugins.js +3 -8
  32. package/dist_ts/mod_services/classes.globalregistry.js +2 -2
  33. package/dist_ts/mod_services/classes.servicemanager.d.ts +2 -2
  34. package/dist_ts/mod_services/classes.servicemanager.js +21 -21
  35. package/dist_ts/plugins.d.ts +2 -2
  36. package/dist_ts/plugins.js +3 -3
  37. package/package.json +4 -10
  38. package/ts/classes.gitzoneconfig.ts +3 -3
  39. package/ts/gitzone.cli.ts +0 -17
  40. package/ts/mod_commit/index.ts +3 -3
  41. package/ts/mod_config/classes.commitconfig.ts +19 -19
  42. package/ts/mod_config/classes.releaseconfig.ts +20 -20
  43. package/ts/mod_config/index.ts +11 -11
  44. package/ts/mod_format/classes.baseformatter.ts +14 -25
  45. package/ts/mod_format/classes.formatplanner.ts +10 -39
  46. package/ts/mod_format/classes.formatstats.ts +2 -42
  47. package/ts/mod_format/formatters/cleanup.formatter.ts +0 -1
  48. package/ts/mod_format/formatters/copy.formatter.ts +4 -8
  49. package/ts/mod_format/formatters/gitignore.formatter.ts +25 -29
  50. package/ts/mod_format/formatters/packagejson.formatter.ts +4 -4
  51. package/ts/mod_format/formatters/prettier.formatter.ts +3 -13
  52. package/ts/mod_format/formatters/smartconfig.formatter.ts +213 -0
  53. package/ts/mod_format/formatters/templates.formatter.ts +0 -9
  54. package/ts/mod_format/formatters/tsconfig.formatter.ts +6 -3
  55. package/ts/mod_format/index.ts +35 -98
  56. package/ts/mod_format/interfaces.format.ts +16 -19
  57. package/ts/mod_format/mod.plugins.ts +2 -12
  58. package/ts/mod_services/classes.globalregistry.ts +2 -2
  59. package/ts/mod_services/classes.servicemanager.ts +20 -20
  60. package/ts/plugins.ts +2 -2
  61. package/dist_ts/mod_format/classes.changecache.d.ts +0 -26
  62. package/dist_ts/mod_format/classes.changecache.js +0 -181
  63. package/dist_ts/mod_format/classes.dependency-analyzer.d.ts +0 -13
  64. package/dist_ts/mod_format/classes.dependency-analyzer.js +0 -93
  65. package/dist_ts/mod_format/classes.rollbackmanager.d.ts +0 -22
  66. package/dist_ts/mod_format/classes.rollbackmanager.js +0 -259
  67. package/dist_ts/mod_format/format.cleanup.d.ts +0 -2
  68. package/dist_ts/mod_format/format.cleanup.js +0 -25
  69. package/dist_ts/mod_format/format.copy.d.ts +0 -24
  70. package/dist_ts/mod_format/format.copy.js +0 -77
  71. package/dist_ts/mod_format/format.gitignore.d.ts +0 -2
  72. package/dist_ts/mod_format/format.gitignore.js +0 -48
  73. package/dist_ts/mod_format/format.license.d.ts +0 -2
  74. package/dist_ts/mod_format/format.license.js +0 -26
  75. package/dist_ts/mod_format/format.npmextra.d.ts +0 -5
  76. package/dist_ts/mod_format/format.npmextra.js +0 -125
  77. package/dist_ts/mod_format/format.packagejson.d.ts +0 -2
  78. package/dist_ts/mod_format/format.packagejson.js +0 -145
  79. package/dist_ts/mod_format/format.prettier.d.ts +0 -2
  80. package/dist_ts/mod_format/format.prettier.js +0 -56
  81. package/dist_ts/mod_format/format.readme.d.ts +0 -1
  82. package/dist_ts/mod_format/format.readme.js +0 -29
  83. package/dist_ts/mod_format/format.templates.d.ts +0 -5
  84. package/dist_ts/mod_format/format.templates.js +0 -68
  85. package/dist_ts/mod_format/format.tsconfig.d.ts +0 -2
  86. package/dist_ts/mod_format/format.tsconfig.js +0 -28
  87. package/dist_ts/mod_format/formatters/npmextra.formatter.js +0 -142
  88. package/ts/mod_format/classes.changecache.ts +0 -235
  89. package/ts/mod_format/classes.dependency-analyzer.ts +0 -117
  90. package/ts/mod_format/classes.rollbackmanager.ts +0 -340
  91. package/ts/mod_format/format.cleanup.ts +0 -26
  92. package/ts/mod_format/format.copy.ts +0 -93
  93. package/ts/mod_format/format.gitignore.ts +0 -54
  94. package/ts/mod_format/format.license.ts +0 -32
  95. package/ts/mod_format/format.npmextra.ts +0 -151
  96. package/ts/mod_format/format.packagejson.ts +0 -196
  97. package/ts/mod_format/format.prettier.ts +0 -66
  98. package/ts/mod_format/format.readme.ts +0 -29
  99. package/ts/mod_format/format.templates.ts +0 -79
  100. package/ts/mod_format/format.tsconfig.ts +0 -31
  101. package/ts/mod_format/formatters/npmextra.formatter.ts +0 -174
  102. /package/{npmextra.json → .smartconfig.json} +0 -0
@@ -1,93 +0,0 @@
1
- import type { Project } from '../classes.project.js';
2
- import * as plugins from './mod.plugins.js';
3
- import { logger } from '../gitzone.logging.js';
4
-
5
- export const run = async (projectArg: Project) => {
6
- const gitzoneConfig = await projectArg.gitzoneConfig;
7
-
8
- // Get copy configuration from npmextra.json
9
- const npmextraConfig = new plugins.npmextra.Smartconfig();
10
- const copyConfig = npmextraConfig.dataFor<any>('gitzone.format.copy', {
11
- patterns: [],
12
- });
13
-
14
- if (!copyConfig.patterns || copyConfig.patterns.length === 0) {
15
- logger.log('info', 'No copy patterns configured in npmextra.json');
16
- return;
17
- }
18
-
19
- for (const pattern of copyConfig.patterns) {
20
- if (!pattern.from || !pattern.to) {
21
- logger.log('warn', 'Invalid copy pattern - missing "from" or "to" field');
22
- continue;
23
- }
24
-
25
- try {
26
- // Handle glob patterns
27
- const entries = await plugins.smartfs
28
- .directory('.')
29
- .recursive()
30
- .filter(pattern.from)
31
- .list();
32
- const files = entries.map((entry) => entry.path);
33
-
34
- for (const file of files) {
35
- const sourcePath = file;
36
- let destPath = pattern.to;
37
-
38
- // If destination is a directory, preserve filename
39
- if (pattern.to.endsWith('/')) {
40
- const filename = plugins.path.basename(file);
41
- destPath = plugins.path.join(pattern.to, filename);
42
- }
43
-
44
- // Handle template variables in destination path
45
- if (pattern.preservePath) {
46
- const relativePath = plugins.path.relative(
47
- plugins.path.dirname(pattern.from.replace(/\*/g, '')),
48
- file,
49
- );
50
- destPath = plugins.path.join(pattern.to, relativePath);
51
- }
52
-
53
- // Ensure destination directory exists
54
- await plugins.smartfs
55
- .directory(plugins.path.dirname(destPath))
56
- .recursive()
57
- .create();
58
-
59
- // Copy file
60
- await plugins.smartfs.file(sourcePath).copy(destPath);
61
- logger.log('info', `Copied ${sourcePath} to ${destPath}`);
62
- }
63
- } catch (error) {
64
- logger.log(
65
- 'error',
66
- `Failed to copy pattern ${pattern.from}: ${error.message}`,
67
- );
68
- }
69
- }
70
- };
71
-
72
- /**
73
- * Example npmextra.json configuration:
74
- * {
75
- * "gitzone": {
76
- * "format": {
77
- * "copy": {
78
- * "patterns": [
79
- * {
80
- * "from": "src/assets/*",
81
- * "to": "dist/assets/",
82
- * "preservePath": true
83
- * },
84
- * {
85
- * "from": "config/*.json",
86
- * "to": "dist/"
87
- * }
88
- * ]
89
- * }
90
- * }
91
- * }
92
- * }
93
- */
@@ -1,54 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
-
4
- import { Project } from '../classes.project.js';
5
-
6
- import { logger } from '../gitzone.logging.js';
7
- const gitignorePath = plugins.path.join(paths.cwd, './.gitignore');
8
-
9
- export const run = async (projectArg: Project) => {
10
- const gitignoreExists = await plugins.smartfs.file(gitignorePath).exists();
11
- let customContent = '';
12
-
13
- if (gitignoreExists) {
14
- // lets get the existing gitignore file
15
- const existingGitIgnoreString = (await plugins.smartfs
16
- .file(gitignorePath)
17
- .encoding('utf8')
18
- .read()) as string;
19
-
20
- // Check for different custom section markers
21
- const customMarkers = ['#------# custom', '# custom'];
22
- for (const marker of customMarkers) {
23
- const splitResult = existingGitIgnoreString.split(marker);
24
- if (splitResult.length > 1) {
25
- // Get everything after the marker (excluding the marker itself)
26
- customContent = splitResult[1].trim();
27
- break;
28
- }
29
- }
30
- }
31
-
32
- // Write the template
33
- const templateModule = await import('../mod_template/index.js');
34
- const ciTemplate = await templateModule.getTemplate('gitignore');
35
- await ciTemplate.writeToDisk(paths.cwd);
36
-
37
- // Append the custom content if it exists
38
- if (customContent) {
39
- const newGitignoreContent = (await plugins.smartfs
40
- .file(gitignorePath)
41
- .encoding('utf8')
42
- .read()) as string;
43
- // The template already ends with "#------# custom", so just append the content
44
- const finalContent =
45
- newGitignoreContent.trimEnd() + '\n' + customContent + '\n';
46
- await plugins.smartfs
47
- .file(gitignorePath)
48
- .encoding('utf8')
49
- .write(finalContent);
50
- logger.log('info', 'Updated .gitignore while preserving custom section!');
51
- } else {
52
- logger.log('info', 'Added a .gitignore!');
53
- }
54
- };
@@ -1,32 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
- import { Project } from '../classes.project.js';
4
-
5
- import { logger } from '../gitzone.logging.js';
6
-
7
- const incompatibleLicenses: string[] = ['AGPL', 'GPL', 'SSPL'];
8
-
9
- export const run = async (projectArg: Project) => {
10
- const nodeModulesInstalled = await plugins.smartfs
11
- .directory(plugins.path.join(paths.cwd, 'node_modules'))
12
- .exists();
13
- if (!nodeModulesInstalled) {
14
- logger.log('warn', 'No node_modules found. Skipping license check');
15
- return;
16
- }
17
- const licenseChecker = await plugins.smartlegal.createLicenseChecker();
18
- const licenseCheckResult = await licenseChecker.excludeLicenseWithinPath(
19
- paths.cwd,
20
- incompatibleLicenses,
21
- );
22
- if (licenseCheckResult.failingModules.length === 0) {
23
- logger.log('info', 'Success -> licenses passed!');
24
- } else {
25
- logger.log('error', 'Error -> licenses failed. Here is why:');
26
- for (const failedModule of licenseCheckResult.failingModules) {
27
- console.log(
28
- `${failedModule.name} fails with license ${failedModule.license}`,
29
- );
30
- }
31
- }
32
- };
@@ -1,151 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
- import * as gulpFunction from '@push.rocks/gulp-function';
4
- import { Project } from '../classes.project.js';
5
-
6
- /**
7
- * Migrates npmextra.json from old namespace keys to new package-scoped keys
8
- */
9
- const migrateNamespaceKeys = (npmextraJson: any): boolean => {
10
- let migrated = false;
11
- const migrations = [
12
- { oldKey: 'gitzone', newKey: '@git.zone/cli' },
13
- { oldKey: 'tsdoc', newKey: '@git.zone/tsdoc' },
14
- { oldKey: 'npmdocker', newKey: '@git.zone/tsdocker' },
15
- { oldKey: 'npmci', newKey: '@ship.zone/szci' },
16
- { oldKey: 'szci', newKey: '@ship.zone/szci' },
17
- ];
18
- for (const { oldKey, newKey } of migrations) {
19
- if (npmextraJson[oldKey]) {
20
- if (!npmextraJson[newKey]) {
21
- // New key doesn't exist - simple rename
22
- npmextraJson[newKey] = npmextraJson[oldKey];
23
- } else {
24
- // New key exists - merge old into new (old values don't overwrite new)
25
- npmextraJson[newKey] = {
26
- ...npmextraJson[oldKey],
27
- ...npmextraJson[newKey],
28
- };
29
- }
30
- delete npmextraJson[oldKey];
31
- migrated = true;
32
- console.log(`Migrated npmextra.json: ${oldKey} -> ${newKey}`);
33
- }
34
- }
35
- return migrated;
36
- };
37
-
38
- /**
39
- * Migrates npmAccessLevel from @ship.zone/szci to @git.zone/cli.release.accessLevel
40
- * This is a one-time migration for projects using the old location
41
- */
42
- const migrateAccessLevel = (npmextraJson: any): boolean => {
43
- const szciConfig = npmextraJson['@ship.zone/szci'];
44
-
45
- // Check if szci has npmAccessLevel that needs to be migrated
46
- if (!szciConfig?.npmAccessLevel) {
47
- return false;
48
- }
49
-
50
- // Check if we already have the new location
51
- const gitzoneConfig = npmextraJson['@git.zone/cli'] || {};
52
- if (gitzoneConfig?.release?.accessLevel) {
53
- // Already migrated, just remove from szci
54
- delete szciConfig.npmAccessLevel;
55
- return true;
56
- }
57
-
58
- // Ensure @git.zone/cli and release exist
59
- if (!npmextraJson['@git.zone/cli']) {
60
- npmextraJson['@git.zone/cli'] = {};
61
- }
62
- if (!npmextraJson['@git.zone/cli'].release) {
63
- npmextraJson['@git.zone/cli'].release = {};
64
- }
65
-
66
- // Migrate the value
67
- npmextraJson['@git.zone/cli'].release.accessLevel = szciConfig.npmAccessLevel;
68
- delete szciConfig.npmAccessLevel;
69
-
70
- console.log(`Migrated npmAccessLevel to @git.zone/cli.release.accessLevel`);
71
- return true;
72
- };
73
-
74
- /**
75
- * runs the npmextra file checking
76
- */
77
- export const run = async (projectArg: Project) => {
78
- const formatSmartstream = new plugins.smartstream.StreamWrapper([
79
- plugins.smartgulp.src([`smartconfig.json`]),
80
- gulpFunction.forEach(async (fileArg: plugins.smartfile.SmartFile) => {
81
- const fileString = fileArg.contents.toString();
82
- const npmextraJson = JSON.parse(fileString);
83
-
84
- // Migrate old namespace keys to new package-scoped keys
85
- migrateNamespaceKeys(npmextraJson);
86
-
87
- // Migrate npmAccessLevel from szci to @git.zone/cli.release.accessLevel
88
- migrateAccessLevel(npmextraJson);
89
-
90
- if (!npmextraJson['@git.zone/cli']) {
91
- npmextraJson['@git.zone/cli'] = {};
92
- }
93
-
94
- const expectedRepoInformation: string[] = [
95
- 'projectType',
96
- 'module.githost',
97
- 'module.gitscope',
98
- 'module.gitrepo',
99
- 'module.description',
100
- 'module.npmPackagename',
101
- 'module.license',
102
- ];
103
-
104
- const interactInstance = new plugins.smartinteract.SmartInteract();
105
- for (const expectedRepoInformationItem of expectedRepoInformation) {
106
- if (
107
- !plugins.smartobject.smartGet(
108
- npmextraJson['@git.zone/cli'],
109
- expectedRepoInformationItem,
110
- )
111
- ) {
112
- interactInstance.addQuestions([
113
- {
114
- message: `What is the value of ${expectedRepoInformationItem}`,
115
- name: expectedRepoInformationItem,
116
- type: 'input',
117
- default: 'undefined variable',
118
- },
119
- ]);
120
- }
121
- }
122
-
123
- const answerbucket = await interactInstance.runQueue();
124
- for (const expectedRepoInformationItem of expectedRepoInformation) {
125
- const cliProvidedValue = answerbucket.getAnswerFor(
126
- expectedRepoInformationItem,
127
- );
128
- if (cliProvidedValue) {
129
- plugins.smartobject.smartAdd(
130
- npmextraJson['@git.zone/cli'],
131
- expectedRepoInformationItem,
132
- cliProvidedValue,
133
- );
134
- }
135
- }
136
-
137
- // delete obsolete
138
- // tbd
139
-
140
- if (!npmextraJson['@ship.zone/szci']) {
141
- npmextraJson['@ship.zone/szci'] = {};
142
- }
143
-
144
- fileArg.setContentsFromString(JSON.stringify(npmextraJson, null, 2));
145
- }),
146
- plugins.smartgulp.replace(),
147
- ]);
148
- await formatSmartstream.run().catch((error) => {
149
- console.log(error);
150
- });
151
- };
@@ -1,196 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
- import * as gulpFunction from '@push.rocks/gulp-function';
4
- import { Project } from '../classes.project.js';
5
-
6
- import { logger } from '../gitzone.logging.js';
7
-
8
- /**
9
- * ensures a certain dependency
10
- */
11
- const ensureDependency = async (
12
- packageJsonObjectArg: any,
13
- position: 'dep' | 'devDep' | 'everywhere',
14
- constraint: 'exclude' | 'include' | 'latest',
15
- dependencyArg: string,
16
- ) => {
17
- const [packageName, version] = dependencyArg.includes('@')
18
- ? dependencyArg.split('@').filter(Boolean)
19
- : [dependencyArg, 'latest'];
20
-
21
- const targetSections: string[] = [];
22
-
23
- switch (position) {
24
- case 'dep':
25
- targetSections.push('dependencies');
26
- break;
27
- case 'devDep':
28
- targetSections.push('devDependencies');
29
- break;
30
- case 'everywhere':
31
- targetSections.push('dependencies', 'devDependencies');
32
- break;
33
- }
34
-
35
- for (const section of targetSections) {
36
- if (!packageJsonObjectArg[section]) {
37
- packageJsonObjectArg[section] = {};
38
- }
39
-
40
- switch (constraint) {
41
- case 'exclude':
42
- delete packageJsonObjectArg[section][packageName];
43
- break;
44
- case 'include':
45
- if (!packageJsonObjectArg[section][packageName]) {
46
- packageJsonObjectArg[section][packageName] =
47
- version === 'latest' ? '^1.0.0' : version;
48
- }
49
- break;
50
- case 'latest':
51
- // Fetch latest version from npm
52
- try {
53
- const registry = new plugins.smartnpm.NpmRegistry();
54
- const packageInfo = await registry.getPackageInfo(packageName);
55
- const latestVersion = packageInfo['dist-tags'].latest;
56
- packageJsonObjectArg[section][packageName] = `^${latestVersion}`;
57
- } catch (error) {
58
- logger.log(
59
- 'warn',
60
- `Could not fetch latest version for ${packageName}, using existing or default`,
61
- );
62
- if (!packageJsonObjectArg[section][packageName]) {
63
- packageJsonObjectArg[section][packageName] =
64
- version === 'latest' ? '^1.0.0' : version;
65
- }
66
- }
67
- break;
68
- }
69
- }
70
- };
71
-
72
- export const run = async (projectArg: Project) => {
73
- const formatStreamWrapper = new plugins.smartstream.StreamWrapper([
74
- plugins.smartgulp.src([`package.json`]),
75
- gulpFunction.forEach(async (fileArg: plugins.smartfile.SmartFile) => {
76
- const npmextraConfig = new plugins.npmextra.Smartconfig(paths.cwd);
77
- const gitzoneData: any = npmextraConfig.dataFor('@git.zone/cli', {});
78
- const fileString = fileArg.contents.toString();
79
- const packageJson = JSON.parse(fileString);
80
-
81
- // metadata
82
- packageJson.repository = {
83
- type: 'git',
84
- url: `https://${gitzoneData.module.githost}/${gitzoneData.module.gitscope}/${gitzoneData.module.gitrepo}.git`,
85
- };
86
- ((packageJson.bugs = {
87
- url: `https://${gitzoneData.module.githost}/${gitzoneData.module.gitscope}/${gitzoneData.module.gitrepo}/issues`,
88
- }),
89
- (packageJson.homepage = `https://${gitzoneData.module.githost}/${gitzoneData.module.gitscope}/${gitzoneData.module.gitrepo}#readme`));
90
-
91
- // Check for module type
92
- if (!packageJson.type) {
93
- logger.log('info', `setting packageJson.type to "module"`);
94
- packageJson.type = 'module';
95
- }
96
-
97
- // Check for private or public
98
- if (packageJson.private !== undefined) {
99
- logger.log(
100
- 'info',
101
- 'Success -> found private/public info in package.json!',
102
- );
103
- } else {
104
- logger.log(
105
- 'error',
106
- 'found no private boolean! Setting it to private for now!',
107
- );
108
- packageJson.private = true;
109
- }
110
-
111
- // Check for license
112
- if (packageJson.license) {
113
- logger.log('info', 'Success -> found license in package.json!');
114
- } else {
115
- logger.log(
116
- 'error',
117
- 'found no license! Setting it to UNLICENSED for now!',
118
- );
119
- packageJson.license = 'UNLICENSED';
120
- }
121
-
122
- // Check for build script
123
- if (packageJson.scripts.build) {
124
- logger.log('info', 'Success -> found build script in package.json!');
125
- } else {
126
- logger.log(
127
- 'error',
128
- 'found no build script! Putting a placeholder there for now!',
129
- );
130
- packageJson.scripts.build = `echo "Not needed for now"`;
131
- }
132
-
133
- // Check for buildDocs script
134
- if (!packageJson.scripts.buildDocs) {
135
- logger.log(
136
- 'info',
137
- 'found no buildDocs script! Putting tsdoc script there now.',
138
- );
139
- packageJson.scripts.buildDocs = `tsdoc`;
140
- }
141
-
142
- // check for files
143
- packageJson.files = [
144
- 'ts/**/*',
145
- 'ts_web/**/*',
146
- 'dist/**/*',
147
- 'dist_*/**/*',
148
- 'dist_ts/**/*',
149
- 'dist_ts_web/**/*',
150
- 'assets/**/*',
151
- 'cli.js',
152
- 'smartconfig.json',
153
- 'readme.md',
154
- ];
155
-
156
- // check for dependencies
157
- // Note: @push.rocks/tapbundle is deprecated - use @git.zone/tstest/tapbundle instead
158
- await ensureDependency(
159
- packageJson,
160
- 'devDep',
161
- 'exclude',
162
- '@push.rocks/tapbundle',
163
- );
164
- await ensureDependency(
165
- packageJson,
166
- 'devDep',
167
- 'latest',
168
- '@git.zone/tstest',
169
- );
170
- await ensureDependency(
171
- packageJson,
172
- 'devDep',
173
- 'latest',
174
- '@git.zone/tsbuild',
175
- );
176
-
177
- // set overrides
178
- const overridesContent = (await plugins.smartfs
179
- .file(plugins.path.join(paths.assetsDir, 'overrides.json'))
180
- .encoding('utf8')
181
- .read()) as string;
182
- const overrides = JSON.parse(overridesContent);
183
- packageJson.pnpm = packageJson.pnpm || {};
184
- packageJson.pnpm.overrides = overrides;
185
-
186
- // exclude
187
- // TODO
188
-
189
- fileArg.setContentsFromString(JSON.stringify(packageJson, null, 2));
190
- }),
191
- plugins.smartgulp.replace(),
192
- ]);
193
- await formatStreamWrapper.run().catch((error) => {
194
- console.log(error);
195
- });
196
- };
@@ -1,66 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import prettier from 'prettier';
3
- import { Project } from '../classes.project.js';
4
-
5
- import { logger } from '../gitzone.logging.js';
6
-
7
- const prettierDefaultTypeScriptConfig: prettier.Options = {
8
- printWidth: 100,
9
- parser: 'typescript',
10
- singleQuote: true,
11
- };
12
-
13
- const prettierDefaultMarkdownConfig: prettier.Options = {
14
- singleQuote: true,
15
- printWidth: 100,
16
- parser: 'markdown',
17
- };
18
-
19
- const filesToFormat = [
20
- `ts/**/*.ts`,
21
- `test/**/*.ts`,
22
- `readme.md`,
23
- `docs/**/*.md`,
24
- ];
25
-
26
- const choosePrettierConfig = (fileArg: plugins.smartfile.SmartFile) => {
27
- switch (fileArg.parsedPath.ext) {
28
- case '.ts':
29
- return prettierDefaultTypeScriptConfig;
30
- case '.md':
31
- return prettierDefaultMarkdownConfig;
32
- default:
33
- return {};
34
- }
35
- };
36
-
37
- const prettierTypeScriptPipestop = plugins.through2.obj(
38
- async (fileArg: plugins.smartfile.SmartFile, enc, cb) => {
39
- const fileString = fileArg.contentBuffer.toString();
40
- const chosenConfig = choosePrettierConfig(fileArg);
41
- const filePasses = await prettier.check(fileString, chosenConfig);
42
- if (filePasses) {
43
- logger.log('info', `OK! -> ${fileArg.path} passes!`);
44
- cb(null);
45
- } else {
46
- logger.log('info', `${fileArg.path} is being reformated!`);
47
- const formatedFileString = await prettier.format(
48
- fileString,
49
- chosenConfig,
50
- );
51
- fileArg.setContentsFromString(formatedFileString);
52
- cb(null, fileArg);
53
- }
54
- },
55
- );
56
-
57
- export const run = async (projectArg: Project) => {
58
- const formatStreamWrapper = new plugins.smartstream.StreamWrapper([
59
- plugins.smartgulp.src(filesToFormat),
60
- prettierTypeScriptPipestop,
61
- plugins.smartgulp.replace(),
62
- ]);
63
- await formatStreamWrapper.run().catch((error) => {
64
- console.log(error);
65
- });
66
- };
@@ -1,29 +0,0 @@
1
- import * as plugins from './mod.plugins.js';
2
- import * as paths from '../paths.js';
3
-
4
- export const run = async () => {
5
- const readmePath = plugins.path.join(paths.cwd, 'readme.md');
6
- const readmeHintsPath = plugins.path.join(paths.cwd, 'readme.hints.md');
7
-
8
- // Check and initialize readme.md if it doesn't exist
9
- const readmeExists = await plugins.smartfs.file(readmePath).exists();
10
- if (!readmeExists) {
11
- await plugins.smartfs.file(readmePath)
12
- .encoding('utf8')
13
- .write('# Project Readme\n\nThis is the initial readme file.');
14
- console.log('Initialized readme.md');
15
- } else {
16
- console.log('readme.md already exists');
17
- }
18
-
19
- // Check and initialize readme.hints.md if it doesn't exist
20
- const readmeHintsExists = await plugins.smartfs.file(readmeHintsPath).exists();
21
- if (!readmeHintsExists) {
22
- await plugins.smartfs.file(readmeHintsPath)
23
- .encoding('utf8')
24
- .write('# Project Readme Hints\n\nThis is the initial readme hints file.');
25
- console.log('Initialized readme.hints.md');
26
- } else {
27
- console.log('readme.hints.md already exists');
28
- }
29
- };