ppackage 2.6.0 → 2.7.1

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 (2) hide show
  1. package/index.js +39 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -13,6 +13,7 @@ const wait = require('nyks/child_process/wait');
13
13
  const trim = require('mout/string/trim');
14
14
  const unique = require('mout/array/unique');
15
15
 
16
+ const get = require('mout/object/get');
16
17
  const set = require('mout/object/set');
17
18
  const drain = require('nyks/stream/drain');
18
19
 
@@ -33,6 +34,8 @@ const COMPOSER_PATH = "composer.json";
33
34
 
34
35
 
35
36
 
37
+
38
+
36
39
  const laxParser = function(body) {
37
40
  const tokens = new Parser().parse(body);
38
41
  const docs = new Composer({merge : true, uniqueKeys : false}).compose(tokens);
@@ -47,7 +50,35 @@ const DOCKER_LABEL_REPOSITORY = "org.opencontainers.image.source";
47
50
  const GITLAB_PATH_VERSION = ".version";
48
51
  const GITLAB_PATH_REPOSITORY = ".repository";
49
52
 
53
+ //https://developer.hashicorp.com/terraform/registry/providers/publishing
54
+ const TF_PROVIDER_PATH = "terraform-registry-manifest.json";
55
+ const TF_PROVIDER_METADATA_VERSION = "metadata.version";
56
+ const TF_PROVIDER_METADATA_REPOSITORY = "metadata.repository";
57
+
58
+
50
59
  let modes = {
60
+
61
+ tf_provider : {
62
+ file : TF_PROVIDER_PATH,
63
+ analyze : function() {
64
+ const body = fs.readFileSync(this.file, 'utf-8');
65
+ this.meta = JSON.parse(body);
66
+ let version = get(this.meta, TF_PROVIDER_METADATA_VERSION);
67
+ let repository = get(this.meta, TF_PROVIDER_METADATA_REPOSITORY);
68
+ return {version, repository};
69
+ },
70
+
71
+ commit : function({version, repository, files}) {
72
+ if(version)
73
+ set(this.meta, TF_PROVIDER_METADATA_VERSION, version);
74
+ if(repository)
75
+ set(this.meta, TF_PROVIDER_METADATA_REPOSITORY, {type : "git", url : repository});
76
+
77
+ fs.writeFileSync(this.file, JSON.stringify(this.meta, null, 2) + "\n");
78
+ files.push(this.file);
79
+ }
80
+ },
81
+
51
82
  gitlab : {
52
83
  file : '.gitlab-ci.yml',
53
84
  analyze : function() {
@@ -70,6 +101,8 @@ let modes = {
70
101
  }
71
102
 
72
103
  },
104
+
105
+
73
106
  composer : {
74
107
  file : 'composer.json',
75
108
  analyze : function() {
@@ -182,7 +215,7 @@ class ppackage {
182
215
 
183
216
 
184
217
  let target_version = version || args.shift();
185
-
218
+ await passthru("git", ["status"]);
186
219
  let dirty = await wait(spawn('git', ["diff-index", "--quiet", "HEAD"])).catch(() => true);
187
220
  if(dirty && !notag)
188
221
  throw "Working directory not clean, aborting";
@@ -219,16 +252,16 @@ class ppackage {
219
252
  }
220
253
 
221
254
 
222
- async gitify(branch = null) {
255
+ async gitify(repository_url = null, branch = "master") {
256
+ if(!repository_url)
257
+ repository_url = args.shift();
223
258
 
224
- if(!branch)
225
- branch = args.shift() || "master";
259
+ if(!repository_url)
260
+ ({repository_url} = await this._find_repo());
226
261
 
227
262
  if(fs.existsSync(GIT_FOLDER))
228
263
  throw `Cowardly aborting working with existing git project`;
229
264
 
230
- let {repository_url} = await this._find_repo();
231
-
232
265
 
233
266
  let cloneopts = ["--bare", "--config", `core.askPass=${path.join(__dirname, "bin/askpass")}`];
234
267
  await passthru("git", ["clone", ...cloneopts, repository_url, GIT_FOLDER]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ppackage",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {