@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.
- package/assets/templates/ci_default/.gitea/workflows/default_nottags.yaml +66 -0
- package/assets/templates/ci_default/.gitea/workflows/default_tags.yaml +124 -0
- package/assets/templates/ci_default_gitlab/.gitlab-ci.yml +128 -0
- package/assets/templates/ci_default_private/.gitea/workflows/default_nottags.yaml +66 -0
- package/assets/templates/ci_default_private/.gitea/workflows/default_tags.yaml +124 -0
- package/assets/templates/ci_default_private_gitlab/.gitlab-ci.yml +133 -0
- package/assets/templates/ci_docker/.gitea/workflows/docker_nottags.yaml +71 -0
- package/assets/templates/ci_docker/.gitea/workflows/docker_tags.yaml +106 -0
- package/assets/templates/ci_docker_gitlab/.gitlab-ci.yml +107 -0
- package/assets/templates/cli/cli.child.ts +4 -0
- package/assets/templates/cli/cli.js +4 -0
- package/assets/templates/cli/cli.ts.js +5 -0
- package/assets/templates/dockerfile_service/Dockerfile +46 -0
- package/assets/templates/dockerfile_service/dockerignore +4 -0
- package/assets/templates/gitignore/_gitignore +23 -0
- package/assets/templates/license_mit/license +19 -0
- package/assets/templates/meta/.meta.json +3 -0
- package/assets/templates/meta/.smartscaf.yml +5 -0
- package/assets/templates/meta/package.json +11 -0
- package/assets/templates/npm/.package.json +28 -0
- package/assets/templates/npm/.smartscaf.yml +24 -0
- package/assets/templates/npm/test/test.ts +8 -0
- package/assets/templates/npm/ts/index.ts +3 -0
- package/assets/templates/npm/ts/some.plugins.ts +7 -0
- package/assets/templates/npmextra/npmextra.json +18 -0
- package/assets/templates/readme/readme.md +5 -0
- package/assets/templates/service/.package.json +34 -0
- package/assets/templates/service/.smartscaf.yml +21 -0
- package/assets/templates/service/npmextra.json +24 -0
- package/assets/templates/service/ts/00_commitinfo_data.ts +8 -0
- package/assets/templates/service/ts/index.ts +4 -0
- package/assets/templates/service/ts/some.classes.some.db.ts +30 -0
- package/assets/templates/service/ts/some.classes.some.ts +27 -0
- package/assets/templates/service/ts/some.paths.ts +9 -0
- package/assets/templates/service/ts/some.plugins.ts +25 -0
- package/assets/templates/tsconfig_update/tsconfig.json +14 -0
- package/assets/templates/vscode/.vscode/launch.json +11 -0
- package/assets/templates/vscode/.vscode/settings.json +26 -0
- package/assets/templates/wcc/.package.json +47 -0
- package/assets/templates/wcc/.smartscaf.yml +20 -0
- package/assets/templates/wcc/ts_web/elements/first-element.ts +47 -0
- package/assets/templates/wcc/ts_web/elements/index.ts +1 -0
- package/assets/templates/wcc/ts_web/index.ts +1 -0
- package/assets/templates/wcc/ts_web/pages/index.ts +2 -0
- package/assets/templates/wcc/ts_web/pages/page1.ts +5 -0
- package/assets/templates/wcc/ts_web/pages/page2.ts +5 -0
- package/assets/templates/wcc_update/html/index.html +25 -0
- package/assets/templates/wcc_update/html/index.ts +10 -0
- package/assets/templates/website/.package.json +40 -0
- package/assets/templates/website/.smartscaf.yml +17 -0
- package/assets/templates/website/Dockerfile +3 -0
- package/assets/templates/website/npmextra.json +24 -0
- package/assets/templates/website/qenv.yml +1 -0
- package/assets/templates/website/readme.md +1 -0
- package/assets/templates/website/ts/ffb.paths.ts +7 -0
- package/assets/templates/website/ts/ffb.plugins.ts +14 -0
- package/assets/templates/website/ts/index.ts +12 -0
- package/assets/templates/website/ts_web/elements/header.ts +62 -0
- package/assets/templates/website/ts_web/index.ts +63 -0
- package/assets/templates/website_update/html/index.html +110 -0
- package/cli.js +4 -0
- package/dist_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/classes.gitzoneconfig.d.ts +31 -0
- package/dist_ts/classes.gitzoneconfig.js +21 -0
- package/dist_ts/classes.project.d.ts +11 -0
- package/dist_ts/classes.project.js +23 -0
- package/dist_ts/gitzone.cli.d.ts +1 -0
- package/dist_ts/gitzone.cli.js +82 -0
- package/dist_ts/gitzone.config.d.ts +28 -0
- package/dist_ts/gitzone.config.js +21 -0
- package/dist_ts/gitzone.logging.d.ts +2 -0
- package/dist_ts/gitzone.logging.js +14 -0
- package/dist_ts/gitzone.monitor.d.ts +1 -0
- package/dist_ts/gitzone.monitor.js +2 -0
- package/dist_ts/gitzone.paths.d.ts +4 -0
- package/dist_ts/gitzone.paths.js +6 -0
- package/dist_ts/gitzone.plugins.d.ts +10 -0
- package/dist_ts/gitzone.plugins.js +11 -0
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +10 -0
- package/dist_ts/mod_audit/index.d.ts +1 -0
- package/dist_ts/mod_audit/index.js +2 -0
- package/dist_ts/mod_commit/index.d.ts +1 -0
- package/dist_ts/mod_commit/index.js +68 -0
- package/dist_ts/mod_commit/mod.plugins.d.ts +5 -0
- package/dist_ts/mod_commit/mod.plugins.js +6 -0
- package/dist_ts/mod_deprecate/index.d.ts +1 -0
- package/dist_ts/mod_deprecate/index.js +34 -0
- package/dist_ts/mod_deprecate/mod.plugins.d.ts +4 -0
- package/dist_ts/mod_deprecate/mod.plugins.js +5 -0
- package/dist_ts/mod_format/format.classes.project.d.ts +8 -0
- package/dist_ts/mod_format/format.classes.project.js +20 -0
- package/dist_ts/mod_format/format.cleanup.d.ts +2 -0
- package/dist_ts/mod_format/format.cleanup.js +18 -0
- package/dist_ts/mod_format/format.copy.d.ts +2 -0
- package/dist_ts/mod_format/format.copy.js +5 -0
- package/dist_ts/mod_format/format.gitignore.d.ts +2 -0
- package/dist_ts/mod_format/format.gitignore.js +19 -0
- package/dist_ts/mod_format/format.license.d.ts +2 -0
- package/dist_ts/mod_format/format.license.js +23 -0
- package/dist_ts/mod_format/format.npmextra.d.ts +5 -0
- package/dist_ts/mod_format/format.npmextra.js +59 -0
- package/dist_ts/mod_format/format.packagejson.d.ts +2 -0
- package/dist_ts/mod_format/format.packagejson.js +104 -0
- package/dist_ts/mod_format/format.prettier.d.ts +2 -0
- package/dist_ts/mod_format/format.prettier.js +51 -0
- package/dist_ts/mod_format/format.readme.d.ts +2 -0
- package/dist_ts/mod_format/format.readme.js +40 -0
- package/dist_ts/mod_format/format.templates.d.ts +5 -0
- package/dist_ts/mod_format/format.templates.js +67 -0
- package/dist_ts/mod_format/index.d.ts +1 -0
- package/dist_ts/mod_format/index.js +30 -0
- package/dist_ts/mod_format/mod.plugins.d.ts +11 -0
- package/dist_ts/mod_format/mod.plugins.js +12 -0
- package/dist_ts/mod_helpers/index.d.ts +1 -0
- package/dist_ts/mod_helpers/index.js +10 -0
- package/dist_ts/mod_helpers/mod.plugins.d.ts +3 -0
- package/dist_ts/mod_helpers/mod.plugins.js +4 -0
- package/dist_ts/mod_meta/index.d.ts +1 -0
- package/dist_ts/mod_meta/index.js +25 -0
- package/dist_ts/mod_meta/meta.classes.meta.d.ts +53 -0
- package/dist_ts/mod_meta/meta.classes.meta.js +174 -0
- package/dist_ts/mod_meta/meta.interfaces.d.ts +5 -0
- package/dist_ts/mod_meta/meta.interfaces.js +2 -0
- package/dist_ts/mod_meta/meta.plugins.d.ts +6 -0
- package/dist_ts/mod_meta/meta.plugins.js +7 -0
- package/dist_ts/mod_open/index.d.ts +1 -0
- package/dist_ts/mod_open/index.js +12 -0
- package/dist_ts/mod_open/mod.plugins.d.ts +4 -0
- package/dist_ts/mod_open/mod.plugins.js +5 -0
- package/dist_ts/mod_standard/index.d.ts +1 -0
- package/dist_ts/mod_standard/index.js +25 -0
- package/dist_ts/mod_standard/mod.plugins.d.ts +3 -0
- package/dist_ts/mod_standard/mod.plugins.js +4 -0
- package/dist_ts/mod_start/index.d.ts +6 -0
- package/dist_ts/mod_start/index.js +22 -0
- package/dist_ts/mod_start/mod.plugins.d.ts +3 -0
- package/dist_ts/mod_start/mod.plugins.js +5 -0
- package/dist_ts/mod_template/index.d.ts +8 -0
- package/dist_ts/mod_template/index.js +47 -0
- package/dist_ts/mod_template/mod.plugins.d.ts +5 -0
- package/dist_ts/mod_template/mod.plugins.js +6 -0
- package/dist_ts/paths.d.ts +4 -0
- package/dist_ts/paths.js +6 -0
- package/dist_ts/plugins.d.ts +11 -0
- package/dist_ts/plugins.js +11 -0
- package/license +19 -0
- package/npmextra.json +34 -0
- package/package.json +107 -0
- package/readme.hints.md +1 -0
- package/readme.md +207 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/classes.gitzoneconfig.ts +47 -0
- package/ts/classes.project.ts +28 -0
- package/ts/gitzone.cli.ts +101 -0
- package/ts/gitzone.logging.ts +15 -0
- package/ts/index.ts +9 -0
- package/ts/mod_audit/index.ts +1 -0
- package/ts/mod_commit/index.ts +73 -0
- package/ts/mod_commit/mod.plugins.ts +7 -0
- package/ts/mod_deprecate/index.ts +37 -0
- package/ts/mod_deprecate/mod.plugins.ts +6 -0
- package/ts/mod_format/format.cleanup.ts +19 -0
- package/ts/mod_format/format.copy.ts +6 -0
- package/ts/mod_format/format.gitignore.ts +21 -0
- package/ts/mod_format/format.license.ts +24 -0
- package/ts/mod_format/format.npmextra.ts +70 -0
- package/ts/mod_format/format.packagejson.ts +120 -0
- package/ts/mod_format/format.prettier.ts +58 -0
- package/ts/mod_format/format.readme.ts +47 -0
- package/ts/mod_format/format.templates.ts +71 -0
- package/ts/mod_format/index.ts +38 -0
- package/ts/mod_format/mod.plugins.ts +13 -0
- package/ts/mod_helpers/index.ts +10 -0
- package/ts/mod_helpers/mod.plugins.ts +5 -0
- package/ts/mod_meta/index.ts +26 -0
- package/ts/mod_meta/meta.classes.meta.ts +234 -0
- package/ts/mod_meta/meta.interfaces.ts +3 -0
- package/ts/mod_meta/meta.plugins.ts +8 -0
- package/ts/mod_open/index.ts +15 -0
- package/ts/mod_open/mod.plugins.ts +5 -0
- package/ts/mod_standard/index.ts +29 -0
- package/ts/mod_standard/mod.plugins.ts +4 -0
- package/ts/mod_start/index.ts +26 -0
- package/ts/mod_start/mod.plugins.ts +6 -0
- package/ts/mod_template/index.ts +52 -0
- package/ts/mod_template/mod.plugins.ts +7 -0
- package/ts/paths.ts +9 -0
- 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,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,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,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,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
|
+
};
|
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
|
+
};
|