@git.zone/cli 1.9.95

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 (190) hide show
  1. package/assets/templates/ci_default/.gitea/workflows/default_nottags.yaml +66 -0
  2. package/assets/templates/ci_default/.gitea/workflows/default_tags.yaml +124 -0
  3. package/assets/templates/ci_default_gitlab/.gitlab-ci.yml +128 -0
  4. package/assets/templates/ci_default_private/.gitea/workflows/default_nottags.yaml +66 -0
  5. package/assets/templates/ci_default_private/.gitea/workflows/default_tags.yaml +124 -0
  6. package/assets/templates/ci_default_private_gitlab/.gitlab-ci.yml +133 -0
  7. package/assets/templates/ci_docker/.gitea/workflows/docker_nottags.yaml +71 -0
  8. package/assets/templates/ci_docker/.gitea/workflows/docker_tags.yaml +106 -0
  9. package/assets/templates/ci_docker_gitlab/.gitlab-ci.yml +107 -0
  10. package/assets/templates/cli/cli.child.ts +4 -0
  11. package/assets/templates/cli/cli.js +4 -0
  12. package/assets/templates/cli/cli.ts.js +5 -0
  13. package/assets/templates/dockerfile_service/Dockerfile +46 -0
  14. package/assets/templates/dockerfile_service/dockerignore +4 -0
  15. package/assets/templates/gitignore/_gitignore +23 -0
  16. package/assets/templates/license_mit/license +19 -0
  17. package/assets/templates/meta/.meta.json +3 -0
  18. package/assets/templates/meta/.smartscaf.yml +5 -0
  19. package/assets/templates/meta/package.json +11 -0
  20. package/assets/templates/npm/.package.json +28 -0
  21. package/assets/templates/npm/.smartscaf.yml +24 -0
  22. package/assets/templates/npm/test/test.ts +8 -0
  23. package/assets/templates/npm/ts/index.ts +3 -0
  24. package/assets/templates/npm/ts/some.plugins.ts +7 -0
  25. package/assets/templates/npmextra/npmextra.json +18 -0
  26. package/assets/templates/readme/readme.md +5 -0
  27. package/assets/templates/service/.package.json +34 -0
  28. package/assets/templates/service/.smartscaf.yml +21 -0
  29. package/assets/templates/service/npmextra.json +24 -0
  30. package/assets/templates/service/ts/00_commitinfo_data.ts +8 -0
  31. package/assets/templates/service/ts/index.ts +4 -0
  32. package/assets/templates/service/ts/some.classes.some.db.ts +30 -0
  33. package/assets/templates/service/ts/some.classes.some.ts +27 -0
  34. package/assets/templates/service/ts/some.paths.ts +9 -0
  35. package/assets/templates/service/ts/some.plugins.ts +25 -0
  36. package/assets/templates/tsconfig_update/tsconfig.json +14 -0
  37. package/assets/templates/vscode/.vscode/launch.json +11 -0
  38. package/assets/templates/vscode/.vscode/settings.json +26 -0
  39. package/assets/templates/wcc/.package.json +47 -0
  40. package/assets/templates/wcc/.smartscaf.yml +20 -0
  41. package/assets/templates/wcc/ts_web/elements/first-element.ts +47 -0
  42. package/assets/templates/wcc/ts_web/elements/index.ts +1 -0
  43. package/assets/templates/wcc/ts_web/index.ts +1 -0
  44. package/assets/templates/wcc/ts_web/pages/index.ts +2 -0
  45. package/assets/templates/wcc/ts_web/pages/page1.ts +5 -0
  46. package/assets/templates/wcc/ts_web/pages/page2.ts +5 -0
  47. package/assets/templates/wcc_update/html/index.html +25 -0
  48. package/assets/templates/wcc_update/html/index.ts +10 -0
  49. package/assets/templates/website/.package.json +40 -0
  50. package/assets/templates/website/.smartscaf.yml +17 -0
  51. package/assets/templates/website/Dockerfile +3 -0
  52. package/assets/templates/website/npmextra.json +24 -0
  53. package/assets/templates/website/qenv.yml +1 -0
  54. package/assets/templates/website/readme.md +1 -0
  55. package/assets/templates/website/ts/ffb.paths.ts +7 -0
  56. package/assets/templates/website/ts/ffb.plugins.ts +14 -0
  57. package/assets/templates/website/ts/index.ts +12 -0
  58. package/assets/templates/website/ts_web/elements/header.ts +62 -0
  59. package/assets/templates/website/ts_web/index.ts +63 -0
  60. package/assets/templates/website_update/html/index.html +110 -0
  61. package/cli.js +4 -0
  62. package/dist_ts/00_commitinfo_data.d.ts +8 -0
  63. package/dist_ts/00_commitinfo_data.js +9 -0
  64. package/dist_ts/classes.gitzoneconfig.d.ts +31 -0
  65. package/dist_ts/classes.gitzoneconfig.js +21 -0
  66. package/dist_ts/classes.project.d.ts +11 -0
  67. package/dist_ts/classes.project.js +23 -0
  68. package/dist_ts/gitzone.cli.d.ts +1 -0
  69. package/dist_ts/gitzone.cli.js +82 -0
  70. package/dist_ts/gitzone.config.d.ts +28 -0
  71. package/dist_ts/gitzone.config.js +21 -0
  72. package/dist_ts/gitzone.logging.d.ts +2 -0
  73. package/dist_ts/gitzone.logging.js +14 -0
  74. package/dist_ts/gitzone.monitor.d.ts +1 -0
  75. package/dist_ts/gitzone.monitor.js +2 -0
  76. package/dist_ts/gitzone.paths.d.ts +4 -0
  77. package/dist_ts/gitzone.paths.js +6 -0
  78. package/dist_ts/gitzone.plugins.d.ts +10 -0
  79. package/dist_ts/gitzone.plugins.js +11 -0
  80. package/dist_ts/index.d.ts +1 -0
  81. package/dist_ts/index.js +10 -0
  82. package/dist_ts/mod_audit/index.d.ts +1 -0
  83. package/dist_ts/mod_audit/index.js +2 -0
  84. package/dist_ts/mod_commit/index.d.ts +1 -0
  85. package/dist_ts/mod_commit/index.js +68 -0
  86. package/dist_ts/mod_commit/mod.plugins.d.ts +5 -0
  87. package/dist_ts/mod_commit/mod.plugins.js +6 -0
  88. package/dist_ts/mod_deprecate/index.d.ts +1 -0
  89. package/dist_ts/mod_deprecate/index.js +34 -0
  90. package/dist_ts/mod_deprecate/mod.plugins.d.ts +4 -0
  91. package/dist_ts/mod_deprecate/mod.plugins.js +5 -0
  92. package/dist_ts/mod_format/format.classes.project.d.ts +8 -0
  93. package/dist_ts/mod_format/format.classes.project.js +20 -0
  94. package/dist_ts/mod_format/format.cleanup.d.ts +2 -0
  95. package/dist_ts/mod_format/format.cleanup.js +18 -0
  96. package/dist_ts/mod_format/format.copy.d.ts +2 -0
  97. package/dist_ts/mod_format/format.copy.js +5 -0
  98. package/dist_ts/mod_format/format.gitignore.d.ts +2 -0
  99. package/dist_ts/mod_format/format.gitignore.js +19 -0
  100. package/dist_ts/mod_format/format.license.d.ts +2 -0
  101. package/dist_ts/mod_format/format.license.js +23 -0
  102. package/dist_ts/mod_format/format.npmextra.d.ts +5 -0
  103. package/dist_ts/mod_format/format.npmextra.js +59 -0
  104. package/dist_ts/mod_format/format.packagejson.d.ts +2 -0
  105. package/dist_ts/mod_format/format.packagejson.js +104 -0
  106. package/dist_ts/mod_format/format.prettier.d.ts +2 -0
  107. package/dist_ts/mod_format/format.prettier.js +51 -0
  108. package/dist_ts/mod_format/format.readme.d.ts +2 -0
  109. package/dist_ts/mod_format/format.readme.js +40 -0
  110. package/dist_ts/mod_format/format.templates.d.ts +5 -0
  111. package/dist_ts/mod_format/format.templates.js +67 -0
  112. package/dist_ts/mod_format/index.d.ts +1 -0
  113. package/dist_ts/mod_format/index.js +30 -0
  114. package/dist_ts/mod_format/mod.plugins.d.ts +11 -0
  115. package/dist_ts/mod_format/mod.plugins.js +12 -0
  116. package/dist_ts/mod_helpers/index.d.ts +1 -0
  117. package/dist_ts/mod_helpers/index.js +10 -0
  118. package/dist_ts/mod_helpers/mod.plugins.d.ts +3 -0
  119. package/dist_ts/mod_helpers/mod.plugins.js +4 -0
  120. package/dist_ts/mod_meta/index.d.ts +1 -0
  121. package/dist_ts/mod_meta/index.js +25 -0
  122. package/dist_ts/mod_meta/meta.classes.meta.d.ts +53 -0
  123. package/dist_ts/mod_meta/meta.classes.meta.js +174 -0
  124. package/dist_ts/mod_meta/meta.interfaces.d.ts +5 -0
  125. package/dist_ts/mod_meta/meta.interfaces.js +2 -0
  126. package/dist_ts/mod_meta/meta.plugins.d.ts +6 -0
  127. package/dist_ts/mod_meta/meta.plugins.js +7 -0
  128. package/dist_ts/mod_open/index.d.ts +1 -0
  129. package/dist_ts/mod_open/index.js +12 -0
  130. package/dist_ts/mod_open/mod.plugins.d.ts +4 -0
  131. package/dist_ts/mod_open/mod.plugins.js +5 -0
  132. package/dist_ts/mod_standard/index.d.ts +1 -0
  133. package/dist_ts/mod_standard/index.js +25 -0
  134. package/dist_ts/mod_standard/mod.plugins.d.ts +3 -0
  135. package/dist_ts/mod_standard/mod.plugins.js +4 -0
  136. package/dist_ts/mod_start/index.d.ts +6 -0
  137. package/dist_ts/mod_start/index.js +22 -0
  138. package/dist_ts/mod_start/mod.plugins.d.ts +3 -0
  139. package/dist_ts/mod_start/mod.plugins.js +5 -0
  140. package/dist_ts/mod_template/index.d.ts +8 -0
  141. package/dist_ts/mod_template/index.js +47 -0
  142. package/dist_ts/mod_template/mod.plugins.d.ts +5 -0
  143. package/dist_ts/mod_template/mod.plugins.js +6 -0
  144. package/dist_ts/paths.d.ts +4 -0
  145. package/dist_ts/paths.js +6 -0
  146. package/dist_ts/plugins.d.ts +11 -0
  147. package/dist_ts/plugins.js +11 -0
  148. package/license +19 -0
  149. package/npmextra.json +34 -0
  150. package/package.json +107 -0
  151. package/readme.hints.md +1 -0
  152. package/readme.md +207 -0
  153. package/ts/00_commitinfo_data.ts +8 -0
  154. package/ts/classes.gitzoneconfig.ts +47 -0
  155. package/ts/classes.project.ts +28 -0
  156. package/ts/gitzone.cli.ts +101 -0
  157. package/ts/gitzone.logging.ts +15 -0
  158. package/ts/index.ts +9 -0
  159. package/ts/mod_audit/index.ts +1 -0
  160. package/ts/mod_commit/index.ts +73 -0
  161. package/ts/mod_commit/mod.plugins.ts +7 -0
  162. package/ts/mod_deprecate/index.ts +37 -0
  163. package/ts/mod_deprecate/mod.plugins.ts +6 -0
  164. package/ts/mod_format/format.cleanup.ts +19 -0
  165. package/ts/mod_format/format.copy.ts +6 -0
  166. package/ts/mod_format/format.gitignore.ts +21 -0
  167. package/ts/mod_format/format.license.ts +24 -0
  168. package/ts/mod_format/format.npmextra.ts +70 -0
  169. package/ts/mod_format/format.packagejson.ts +120 -0
  170. package/ts/mod_format/format.prettier.ts +58 -0
  171. package/ts/mod_format/format.readme.ts +47 -0
  172. package/ts/mod_format/format.templates.ts +71 -0
  173. package/ts/mod_format/index.ts +38 -0
  174. package/ts/mod_format/mod.plugins.ts +13 -0
  175. package/ts/mod_helpers/index.ts +10 -0
  176. package/ts/mod_helpers/mod.plugins.ts +5 -0
  177. package/ts/mod_meta/index.ts +26 -0
  178. package/ts/mod_meta/meta.classes.meta.ts +234 -0
  179. package/ts/mod_meta/meta.interfaces.ts +3 -0
  180. package/ts/mod_meta/meta.plugins.ts +8 -0
  181. package/ts/mod_open/index.ts +15 -0
  182. package/ts/mod_open/mod.plugins.ts +5 -0
  183. package/ts/mod_standard/index.ts +29 -0
  184. package/ts/mod_standard/mod.plugins.ts +4 -0
  185. package/ts/mod_start/index.ts +26 -0
  186. package/ts/mod_start/mod.plugins.ts +6 -0
  187. package/ts/mod_template/index.ts +52 -0
  188. package/ts/mod_template/mod.plugins.ts +7 -0
  189. package/ts/paths.ts +9 -0
  190. package/ts/plugins.ts +21 -0
@@ -0,0 +1,234 @@
1
+ import * as plugins from './meta.plugins.js';
2
+ import * as paths from '../paths.js';
3
+ import * as interfaces from './meta.interfaces.js';
4
+
5
+ import { logger } from '../gitzone.logging.js';
6
+
7
+ export class Meta {
8
+ public cwd: string;
9
+ public dirName: string;
10
+ public filePaths: {
11
+ metaJson: string;
12
+ gitIgnore: string;
13
+ packageJson: string;
14
+ };
15
+
16
+ constructor(cwdArg: string) {
17
+ this.cwd = cwdArg;
18
+ this.dirName = plugins.path.basename(this.cwd);
19
+ this.filePaths = {
20
+ metaJson: plugins.path.join(this.cwd, './.meta.json'),
21
+ gitIgnore: plugins.path.join(this.cwd, './.gitignore'),
22
+ packageJson: plugins.path.join(this.cwd, './package.json'),
23
+ };
24
+ }
25
+
26
+ /**
27
+ * the meta repo data
28
+ */
29
+ public metaRepoData: interfaces.IMetaRepoData;
30
+ public smartshellInstance = new plugins.smartshell.Smartshell({
31
+ executor: 'bash',
32
+ });
33
+
34
+ /**
35
+ * sorts the metaRepoData
36
+ */
37
+ public async sortMetaRepoData() {
38
+ const stringifiedMetadata = plugins.smartjson.stringify(this.metaRepoData, []);
39
+ this.metaRepoData = plugins.smartjson.parse(stringifiedMetadata);
40
+ }
41
+
42
+ /**
43
+ * reads the meta file from disk
44
+ */
45
+ public async readDirectory() {
46
+ await this.syncToRemote(true);
47
+ logger.log('info', `reading directory`);
48
+ const metaFileExists = plugins.smartfile.fs.fileExistsSync(this.filePaths.metaJson);
49
+ if (!metaFileExists) {
50
+ throw new Error(`meta file does not exist at ${this.filePaths.metaJson}`);
51
+ }
52
+ this.metaRepoData = plugins.smartfile.fs.toObjectSync(this.filePaths.metaJson);
53
+ }
54
+
55
+ /**
56
+ * generates the gitignore file and stores it on disk
57
+ */
58
+ public async generateGitignore(): Promise<string> {
59
+ await this.sortMetaRepoData();
60
+ let gitignoreString = `# ignored repo directories\n`;
61
+ gitignoreString += `.nogit/\n`;
62
+ gitignoreString += `.pnpm-store/\n`;
63
+ for (const key of Object.keys(this.metaRepoData.projects)) {
64
+ gitignoreString = `${gitignoreString}${key}\n`;
65
+ }
66
+ return gitignoreString;
67
+ }
68
+
69
+ /**
70
+ * write to disk
71
+ */
72
+ public async writeToDisk() {
73
+ // write .meta.json to disk
74
+ plugins.smartfile.memory.toFsSync(
75
+ JSON.stringify(this.metaRepoData, null, 2),
76
+ this.filePaths.metaJson
77
+ );
78
+ // write .gitignore to disk
79
+ plugins.smartfile.memory.toFsSync(await this.generateGitignore(), this.filePaths.gitIgnore);
80
+ }
81
+
82
+ /**
83
+ * push to remote
84
+ */
85
+ public async syncToRemote(gitCleanArg = false) {
86
+ logger.log('info', `syncing from origin master`);
87
+ await this.smartshellInstance.exec(`cd ${this.cwd} && git pull origin master`);
88
+ if (gitCleanArg) {
89
+ logger.log('info', `cleaning the repository from old directories`);
90
+ await this.smartshellInstance.exec(`cd ${this.cwd} && git clean -fd`);
91
+ }
92
+ logger.log('info', `syncing to remote origin master`);
93
+ await this.smartshellInstance.exec(`cd ${this.cwd} && git push origin master`);
94
+ }
95
+
96
+ /**
97
+ * update the locally cloned repositories
98
+ */
99
+ public async updateLocalRepos() {
100
+ await this.syncToRemote();
101
+ const projects = plugins.smartfile.fs.toObjectSync(this.filePaths.metaJson).projects;
102
+ const preExistingFolders = plugins.smartfile.fs.listFoldersSync(this.cwd);
103
+ for (const preExistingFolderArg of preExistingFolders) {
104
+ if (
105
+ preExistingFolderArg !== '.git' &&
106
+ !Object.keys(projects).find((projectFolder) =>
107
+ projectFolder.startsWith(preExistingFolderArg)
108
+ )
109
+ ) {
110
+ const response = await plugins.smartinteraction.SmartInteract.getCliConfirmation(
111
+ `Do you want to delete superfluous directory >>${preExistingFolderArg}<< ?`,
112
+ true
113
+ );
114
+ if (response) {
115
+ logger.log('warn', `Deleting >>${preExistingFolderArg}<<!`);
116
+ } else {
117
+ logger.log('warn', `Not deleting ${preExistingFolderArg} by request!`);
118
+ }
119
+ }
120
+ }
121
+
122
+ await this.readDirectory();
123
+ await this.sortMetaRepoData();
124
+ const missingRepos: string[] = [];
125
+ for (const key of Object.keys(this.metaRepoData.projects)) {
126
+ plugins.smartfile.fs.isDirectory(key)
127
+ ? logger.log('ok', `${key} -> is already cloned`)
128
+ : missingRepos.push(key);
129
+ }
130
+
131
+ logger.log('info', `found ${missingRepos.length} missing repos`);
132
+ for (const missingRepo of missingRepos) {
133
+ await this.smartshellInstance.exec(
134
+ `cd ${this.cwd} && git clone ${this.metaRepoData.projects[missingRepo]} ${missingRepo}`
135
+ );
136
+ }
137
+
138
+ logger.log('info', `write changes to disk`);
139
+ await this.writeToDisk();
140
+
141
+ logger.log('info', `persist changes with a git commit`);
142
+ await this.smartshellInstance.exec(
143
+ `cd ${this.cwd} && git add -A && git commit -m "updated structure"`
144
+ );
145
+ await this.syncToRemote();
146
+
147
+ // go recursive
148
+ const folders = await plugins.smartfile.fs.listFolders(this.cwd);
149
+ const childMetaRepositories: string[] = [];
150
+ for (const folder of folders) {
151
+ logger.log('info', folder);
152
+ }
153
+ console.log('Recursion still needs to be implemented');
154
+ }
155
+
156
+ // project manipulation
157
+
158
+ /**
159
+ * init a new meta project
160
+ */
161
+ public async initProject() {
162
+ await this.syncToRemote(true);
163
+ const fileExists = await plugins.smartfile.fs.fileExists(this.filePaths.metaJson);
164
+ if (!fileExists) {
165
+ await plugins.smartfile.memory.toFs(
166
+ JSON.stringify({
167
+ projects: {},
168
+ }),
169
+ this.filePaths.metaJson
170
+ );
171
+ logger.log(`success`, `created a new .meta.json in directory ${this.cwd}`);
172
+ await plugins.smartfile.memory.toFs(
173
+ JSON.stringify({
174
+ name: this.dirName,
175
+ version: '1.0.0',
176
+ }),
177
+ this.filePaths.packageJson
178
+ );
179
+ logger.log(`success`, `created a new package.json in directory ${this.cwd}`);
180
+ } else {
181
+ logger.log(`error`, `directory ${this.cwd} already has a .metaJson file. Doing nothing.`);
182
+ }
183
+ await this.smartshellInstance.exec(
184
+ `cd ${this.cwd} && git add -A && git commit -m "feat(project): init meta project for ${this.dirName}"`
185
+ );
186
+ await this.updateLocalRepos();
187
+ }
188
+
189
+ /**
190
+ * adds a project
191
+ */
192
+ public async addProject(projectNameArg: string, gitUrlArg) {
193
+ await this.readDirectory();
194
+
195
+ const existingProject = this.metaRepoData.projects[projectNameArg];
196
+
197
+ if (existingProject) {
198
+ throw new Error('Project already exists! Please remove it first before adding it again.');
199
+ }
200
+
201
+ this.metaRepoData.projects[projectNameArg] = gitUrlArg;
202
+
203
+ await this.sortMetaRepoData();
204
+ await this.writeToDisk();
205
+ await this.smartshellInstance.exec(
206
+ `cd ${this.cwd} && git add -A && git commit -m "feat(project): add ${projectNameArg}"`
207
+ );
208
+ await this.updateLocalRepos();
209
+ }
210
+
211
+ /**
212
+ * removes a project
213
+ */
214
+ public async removeProject(projectNameArg: string) {
215
+ await this.readDirectory();
216
+
217
+ const existingProject = this.metaRepoData.projects[projectNameArg];
218
+
219
+ if (!existingProject) {
220
+ logger.log('error', `Project ${projectNameArg} does not exist! So it cannot be removed`);
221
+ return;
222
+ }
223
+
224
+ delete this.metaRepoData.projects[projectNameArg];
225
+
226
+ logger.log('info', 'removing project from .meta.json');
227
+ await this.sortMetaRepoData();
228
+ await this.writeToDisk();
229
+
230
+ logger.log('info', 'removing directory from cwd');
231
+ await plugins.smartfile.fs.remove(plugins.path.join(paths.cwd, projectNameArg));
232
+ await this.updateLocalRepos();
233
+ }
234
+ }
@@ -0,0 +1,3 @@
1
+ export interface IMetaRepoData {
2
+ projects: { [key: string]: string };
3
+ }
@@ -0,0 +1,8 @@
1
+ export * from '../plugins.js';
2
+
3
+ import * as smartfile from '@push.rocks/smartfile';
4
+ import * as smartinteraction from '@push.rocks/smartinteract';
5
+ import * as smartjson from '@push.rocks/smartjson';
6
+ import * as smartshell from '@push.rocks/smartshell';
7
+
8
+ export { smartfile, smartinteraction, smartjson, smartshell };
@@ -0,0 +1,15 @@
1
+ import * as plugins from './mod.plugins.js';
2
+ import * as paths from '../paths.js';
3
+
4
+ export let run = (argvArg) => {
5
+ let projectInfo = new plugins.projectinfo.ProjectInfo(paths.cwd);
6
+ if (argvArg._[1] === 'ci') {
7
+ plugins.smartopen.openUrl(
8
+ `https://gitlab.com/${projectInfo.git.gituser}/${projectInfo.git.gitrepo}/settings/ci_cd`
9
+ );
10
+ } else if (argvArg._[1] === 'pipelines') {
11
+ plugins.smartopen.openUrl(
12
+ `https://gitlab.com/${projectInfo.git.gituser}/${projectInfo.git.gitrepo}/pipelines`
13
+ );
14
+ }
15
+ };
@@ -0,0 +1,5 @@
1
+ export * from '../plugins.js';
2
+ import * as smartopen from '@push.rocks/smartopen';
3
+ import * as projectinfo from '@push.rocks/projectinfo';
4
+
5
+ export { projectinfo, smartopen };
@@ -0,0 +1,29 @@
1
+ /* -----------------------------------------------
2
+ * executes as standard task
3
+ * ----------------------------------------------- */
4
+ import * as plugins from './mod.plugins.js';
5
+ import * as paths from '../paths.js';
6
+
7
+ import { logger } from '../gitzone.logging.js';
8
+
9
+ export let run = () => {
10
+ const done = plugins.smartpromise.defer();
11
+ logger.log('warn', 'no action specified');
12
+ logger.log(
13
+ 'info',
14
+ `
15
+ You can do one of the following things:
16
+ * create a new project with 'gitzone template [template]'
17
+ the following templates exist: ${(() => {
18
+ let projects = `\n`;
19
+ for (const template of plugins.smartfile.fs.listFoldersSync(paths.templatesDir)) {
20
+ projects += ` - ${template}\n`;
21
+ }
22
+ return projects;
23
+ })()}
24
+ * format a project with 'gitzone format'
25
+ `
26
+ );
27
+ done.resolve();
28
+ return done.promise;
29
+ };
@@ -0,0 +1,4 @@
1
+ export * from '../plugins.js';
2
+
3
+ import * as smartfile from '@push.rocks/smartfile';
4
+ export { smartfile };
@@ -0,0 +1,26 @@
1
+ import * as plugins from './mod.plugins.js';
2
+ import * as paths from '../paths.js';
3
+
4
+ import { logger } from '../gitzone.logging.js';
5
+
6
+ /**
7
+ * executes basic project setup for continuing to work.
8
+ * TODO: switch to smartgit
9
+ * @param argvArg
10
+ */
11
+ export const run = async (argvArg: any) => {
12
+ logger.log('info', `preparing the project at ${paths.cwd} for development`);
13
+ const smartshellInstance = new plugins.smartshell.Smartshell({
14
+ executor: 'bash',
15
+ });
16
+
17
+ await smartshellInstance.execStrict(`cd ${paths.cwd} && git checkout master`);
18
+ await smartshellInstance.execStrict(`cd ${paths.cwd} && git pull origin master`);
19
+ await smartshellInstance.execStrict(`cd ${paths.cwd} && npm ci`);
20
+
21
+ await provideNoGitFiles();
22
+ };
23
+
24
+ const provideNoGitFiles = async () => {
25
+ logger.log('warn', 'nogit provision not yet implemented!');
26
+ };
@@ -0,0 +1,6 @@
1
+ export * from '../plugins.js';
2
+
3
+ // pushrocks scope
4
+ import * as smartshell from '@push.rocks/smartshell';
5
+
6
+ export { smartshell };
@@ -0,0 +1,52 @@
1
+ import * as plugins from './mod.plugins.js';
2
+ import * as paths from '../paths.js';
3
+
4
+ import { logger } from '../gitzone.logging.js';
5
+
6
+ export const getTemplatePath = (templateNameArg: string) => {
7
+ return plugins.path.join(paths.templatesDir, templateNameArg);
8
+ };
9
+
10
+ /**
11
+ * receives a template name and returns wether there is a corresponding template
12
+ */
13
+ export const isTemplate = async (templateNameArg: string) => {
14
+ return plugins.smartfile.fs.isDirectory(getTemplatePath(templateNameArg));
15
+ };
16
+
17
+ export const getTemplate = async (templateNameArg: string) => {
18
+ if (isTemplate(templateNameArg)) {
19
+ const localScafTemplate = new plugins.smartscaf.ScafTemplate(getTemplatePath(templateNameArg));
20
+ await localScafTemplate.readTemplateFromDir();
21
+ return localScafTemplate;
22
+ } else {
23
+ return null;
24
+ }
25
+ };
26
+
27
+ export const run = async (argvArg: any) => {
28
+ let chosenTemplate: string = argvArg._[1];
29
+
30
+ if (!chosenTemplate) {
31
+ const smartinteract = new plugins.smartinteract.SmartInteract();
32
+ const answerBucket = await smartinteract.askQuestion({
33
+ type: 'list',
34
+ default: 'npm',
35
+ message: 'What template do you want to scaffold? (Only showing mpost common options)',
36
+ name: 'templateName',
37
+ choices: ['npm', 'service', 'wcc', 'website'],
38
+ });
39
+ chosenTemplate = answerBucket.value;
40
+ }
41
+
42
+ if (await isTemplate(chosenTemplate)) {
43
+ logger.log('info', `found requested template ${chosenTemplate}`);
44
+ } else {
45
+ logger.log('error', `Template ${chosenTemplate} not available`);
46
+ return;
47
+ }
48
+
49
+ const localScafTemplate = await getTemplate(chosenTemplate);
50
+ await localScafTemplate.askCliForMissingVariables();
51
+ await localScafTemplate.writeToDisk(paths.cwd);
52
+ };
@@ -0,0 +1,7 @@
1
+ export * from '../plugins.js';
2
+
3
+ import * as smartfile from '@push.rocks/smartfile';
4
+ import * as smartinteract from '@push.rocks/smartinteract';
5
+ import * as smartscaf from '@push.rocks/smartscaf';
6
+
7
+ export { smartfile, smartinteract, smartscaf };
package/ts/paths.ts ADDED
@@ -0,0 +1,9 @@
1
+ import * as plugins from './plugins.js';
2
+
3
+ export let packageDir = plugins.path.join(
4
+ plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
5
+ '../'
6
+ );
7
+ export let assetsDir = plugins.path.join(packageDir, './assets');
8
+ export let templatesDir = plugins.path.join(assetsDir, 'templates');
9
+ export let cwd = process.cwd();
package/ts/plugins.ts ADDED
@@ -0,0 +1,21 @@
1
+ import * as smartlog from '@push.rocks/smartlog';
2
+ import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
3
+ import * as npmextra from '@push.rocks/npmextra';
4
+ import * as path from 'path';
5
+ import * as projectinfo from '@push.rocks/projectinfo';
6
+ import * as smartcli from '@push.rocks/smartcli';
7
+ import * as smartpath from '@push.rocks/smartpath';
8
+ import * as smartpromise from '@push.rocks/smartpromise';
9
+ import * as smartupdate from '@push.rocks/smartupdate';
10
+
11
+ export {
12
+ smartlog,
13
+ smartlogDestinationLocal,
14
+ npmextra,
15
+ path,
16
+ projectinfo,
17
+ smartcli,
18
+ smartpath,
19
+ smartpromise,
20
+ smartupdate,
21
+ };