Skip to content

Commit

Permalink
GH Action Standards
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie authored and github-actions[bot] committed Jan 23, 2024
1 parent c6d5770 commit 7a2c639
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 123 deletions.
56 changes: 0 additions & 56 deletions docs/reference/Source_Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -1274,9 +1274,6 @@ A helper for any functions that are agnostic in handlers.

* [utils](#module_utils)
* [~isPackageNameBanned(name)](#module_utils..isPackageNameBanned) ⇒ <code>object</code>
* [~constructPackageObjectFull(pack)](#module_utils..constructPackageObjectFull) ⇒ <code>object</code>
* [~constructPackageObjectShort(pack)](#module_utils..constructPackageObjectShort) ⇒ <code>object</code> \| <code>array</code>
* [~constructPackageObjectJSON(pack)](#module_utils..constructPackageObjectJSON) ⇒ <code>object</code>
* [~engineFilter()](#module_utils..engineFilter) ⇒ <code>object</code>
* [~semverArray(semver)](#module_utils..semverArray) ⇒ <code>array</code> \| <code>null</code>
* [~semverGt(a1, a2)](#module_utils..semverGt) ⇒ <code>boolean</code>
Expand All @@ -1301,59 +1298,6 @@ false otherwise.
| --- | --- | --- |
| name | <code>string</code> | The name of the package to check if it is banned. |

<a name="module_utils..constructPackageObjectFull"></a>

### utils~constructPackageObjectFull(pack) ⇒ <code>object</code>
Takes the raw return of a full row from database.getPackageByName() and
constructs a standardized package object full from it.
This should be called only on the data provided by database.getPackageByName(),
otherwise the behavior is unexpected.

**Kind**: inner method of [<code>utils</code>](#module_utils)
**Returns**: <code>object</code> - A properly formatted and converted Package Object Full.
**See**

- [https://github.com/confused-Techie/atom-backend/blob/main/docs/returns.md#package-object-full](https://github.com/confused-Techie/atom-backend/blob/main/docs/returns.md#package-object-full)
- [https://github.com/confused-Techie/atom-backend/blob/main/docs/queries.md#retrieve-single-package--package-object-full](https://github.com/confused-Techie/atom-backend/blob/main/docs/queries.md#retrieve-single-package--package-object-full)


| Param | Type | Description |
| --- | --- | --- |
| pack | <code>object</code> | The anticipated raw SQL return that contains all data to construct a Package Object Full. |

<a name="module_utils..constructPackageObjectShort"></a>

### utils~constructPackageObjectShort(pack) ⇒ <code>object</code> \| <code>array</code>
Takes a single or array of rows from the db, and returns a JSON
construction of package object shorts

**Kind**: inner method of [<code>utils</code>](#module_utils)
**Returns**: <code>object</code> \| <code>array</code> - A properly formatted and converted Package Object Short.
**See**

- [https://github.com/confused-Techie/atom-backend/blob/main/docs/returns.md#package-object-short](https://github.com/confused-Techie/atom-backend/blob/main/docs/returns.md#package-object-short)
- [https://github.com/confused-Techie/atom-backend/blob/main/docs/queries.md#retrieve-many-sorted-packages--package-object-short](https://github.com/confused-Techie/atom-backend/blob/main/docs/queries.md#retrieve-many-sorted-packages--package-object-short)


| Param | Type | Description |
| --- | --- | --- |
| pack | <code>object</code> | The anticipated raw SQL return that contains all data to construct a Package Object Short. |

<a name="module_utils..constructPackageObjectJSON"></a>

### utils~constructPackageObjectJSON(pack) ⇒ <code>object</code>
Takes the return of getPackageVersionByNameAndVersion and returns
a recreation of the package.json with a modified dist.tarball key, pointing
to this server for download.

**Kind**: inner method of [<code>utils</code>](#module_utils)
**Returns**: <code>object</code> - A properly formatted Package Object Mini.
**See**: [https://github.com/confused-Techie/atom-backend/blob/main/docs/returns.md#package-object-mini](https://github.com/confused-Techie/atom-backend/blob/main/docs/returns.md#package-object-mini)

| Param | Type | Description |
| --- | --- | --- |
| pack | <code>object</code> | The expected raw SQL return of `getPackageVersionByNameAndVersion` |

<a name="module_utils..engineFilter"></a>

### utils~engineFilter() ⇒ <code>object</code>
Expand Down
38 changes: 24 additions & 14 deletions docs/resources/complexity-report.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Complexity report, 1/20/2024

* Mean per-function logical LOC: 14.271929824561404
* Mean per-function parameter count: 0.1324561403508772
* Mean per-function cyclomatic complexity: 1.1736842105263159
* Mean per-function Halstead effort: 3371.505283870604
* Mean per-module maintainability index: 69.2796371850002
* First-order density: 0.9233610341643583%
* Change cost: 5.786395814096645%
# Complexity report, 1/23/2024

* Mean per-function logical LOC: 14.663793103448276
* Mean per-function parameter count: 0.13017241379310346
* Mean per-function cyclomatic complexity: 1.170689655172414
* Mean per-function Halstead effort: 3426.6136676441265
* Mean per-module maintainability index: 68.88659389428372
* First-order density: 0.89179548156956%
* Change cost: 5.618311533888228%
* Core size: 100%

## /home/runner/work/package-backend/package-backend/jest.config.js
Expand Down Expand Up @@ -61,13 +61,13 @@

## /home/runner/work/package-backend/package-backend/src/context.js

* Physical LOC: 15
* Logical LOC: 14
* Physical LOC: 20
* Logical LOC: 18
* Mean parameter count: 0
* Cyclomatic complexity: 1
* Cyclomatic complexity density: 7.142857142857142%
* Maintainability index: 60.516428793372064
* Dependency count: 13
* Cyclomatic complexity density: 5.555555555555555%
* Maintainability index: 57.55605134290526
* Dependency count: 16

## /home/runner/work/package-backend/package-backend/docs/resources/jsdoc_typedef.js

Expand Down Expand Up @@ -529,6 +529,16 @@
* Maintainability index: 73.83569622868538
* Dependency count: 2

## /home/runner/work/package-backend/package-backend/tests/models/packageObjectJSON.js

* Physical LOC: 43
* Logical LOC: 33
* Mean parameter count: 0
* Cyclomatic complexity: 1
* Cyclomatic complexity density: 3.0303030303030303%
* Maintainability index: 49.44350377391116
* Dependency count: 0

## /home/runner/work/package-backend/package-backend/tests/models/packageObjectShort.js

* Physical LOC: 137
Expand Down
2 changes: 1 addition & 1 deletion src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ module.exports = {
constructPackageObjectFull: require("./models/constructPackageObjectFull.js"),
constructPackageObjectShort: require("./models/constructPackageObjectShort.js"),
constructPackageObjectJSON: require("./models/constructPackageObjectJSON.js"),
}
},
};
8 changes: 4 additions & 4 deletions src/controllers/getPackagesPackageNameVersionsVersionName.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ module.exports = {
200: {
description: "The `package.json` among other details of the package.",
content: {
"application/json": "$packageObjectJSON"
}
}
}
"application/json": "$packageObjectJSON",
},
},
},
},
endpoint: {
method: "GET",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module.exports = {
"Previously undocumented endpoint. Allows for installation of a package.",
responses: {
302: {
description: "Redirect to the GitHub tarball URL."
}
}
description: "Redirect to the GitHub tarball URL.",
},
},
},
endpoint: {
method: "GET",
Expand Down
4 changes: 3 additions & 1 deletion src/controllers/getThemesFeatured.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ module.exports = {
return sso.notOk().addContent(col).addCalls("db.getFeaturedThemes", col);
}

const newCol = await context.models.constructPackageObjectShort(col.content);
const newCol = await context.models.constructPackageObjectShort(
col.content
);

const sso = new context.sso();

Expand Down
5 changes: 2 additions & 3 deletions src/models/constructPackageObjectFull.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
const logger = require("../logger.js");
const { server_url } = require("../config.js").getConfig();

module.exports =
async function constructPackageObjectFull(pack) {
module.exports = async function constructPackageObjectFull(pack) {
const parseVersions = (vers) => {
let retVer = {};

Expand Down Expand Up @@ -60,4 +59,4 @@ async function constructPackageObjectFull(pack) {
logger.generic(6, "Built Package Object Full without Error");

return newPack;
}
};
5 changes: 2 additions & 3 deletions src/models/constructPackageObjectJSON.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
const logger = require("../logger.js");
const { server_url } = require("../config.js").getConfig();

module.exports =
async function constructPackageObjectJSON(pack) {
module.exports = async function constructPackageObjectJSON(pack) {
const parseVersionObject = (v) => {
let newPack = v.meta;
if (newPack.sha) {
Expand Down Expand Up @@ -43,4 +42,4 @@ async function constructPackageObjectJSON(pack) {

logger.generic(66, "Array Package Object JSON finished without Error");
return arrPack;
}
};
5 changes: 2 additions & 3 deletions src/models/constructPackageObjectShort.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

const logger = require("../logger.js");

module.exports =
async function constructPackageObjectShort(pack) {
module.exports = async function constructPackageObjectShort(pack) {
const parsePackageObject = (p) => {
let newPack = p.data;
newPack.downloads = p.downloads;
Expand Down Expand Up @@ -77,4 +76,4 @@ async function constructPackageObjectShort(pack) {

logger.generic(6, "Single Package Object Short Constructor without Error");
return parsePackageObject(pack);
}
};
27 changes: 12 additions & 15 deletions tests/models/packageObjectJSON.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
module.exports = {
schema: {
description: "The `package.json` of a package with an added `dist.tarball` object.",
description:
"The `package.json` of a package with an added `dist.tarball` object.",
type: "object",
required: [
"name",
"version",
"engines",
"dist"
],
required: ["name", "version", "engines", "dist"],
properties: {
name: { type: "string" },
version: { type: "object" },
engines: { type: "object" },
dist: { type: "object" }
}
dist: { type: "object" },
},
},
example: {
// This is the full return of `language-robots-txt`
Expand All @@ -23,24 +19,25 @@ module.exports = {
author: "confused-Techie",
license: "MIT",
scripts: {
test: "pulsar --test spec"
test: "pulsar --test spec",
},
version: "1.0.8",
keywords: [ "text-mate", "pulsar-package", "pulsar-edit" ],
keywords: ["text-mate", "pulsar-package", "pulsar-edit"],
repository: "https://github.com/confused-Techei/language-robots-txt",
description: "Robots.txt Syntax Highlighting in Pulsar",
dist: {
tarball: "https://api.pulsar-edit.dev/api/packages/language-robots-txt/versions/1.0.8/tarball"
}
tarball:
"https://api.pulsar-edit.dev/api/packages/language-robots-txt/versions/1.0.8/tarball",
},
},
test: Joi.object({
name: Joi.string().required(),
version: Joi.string().required(),
engines: Joi.object({
atom: Joi.string().required()
atom: Joi.string().required(),
}).required(),
dist: Joi.object({
tarball: Joi.string().required()
tarball: Joi.string().required(),
}).required(),
}).required(),
};
19 changes: 9 additions & 10 deletions tests/unit/models/constructPackageObjectFull.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const pof = require("../../../src/models/constructPackageObjectFull.js");
const schema = require("../../models/packageObjectFull.js").test;

describe("Parses Data, as expected to be returned by the Database", () => {

test("Correctly Parses normal data", async () => {
const data = {
pointer: "1234",
Expand All @@ -18,22 +17,22 @@ describe("Parses Data, as expected to be returned by the Database", () => {
metadata: {
name: "test-package",
license: "MIT",
version: "1.0.0"
version: "1.0.0",
},
releases: { latest: "1.0.0" },
versions: {
"1.0.0": {
sha: "1234",
name: "test-package",
version: "1.0.0",
tarball_url: "https://nowhere.com"
}
tarball_url: "https://nowhere.com",
},
},
repository: {
url: "https://github.com/pulsar-edit/test-package",
type: "git"
type: "git",
},
creation_method: "Test Package"
creation_method: "Test Package",
},
owner: "pulsar-edit",
stargazers_count: "1",
Expand All @@ -44,17 +43,17 @@ describe("Parses Data, as expected to be returned by the Database", () => {
sha: "1234",
name: "test-package",
version: "1.0.0",
tarball_url: "https://nowhere.com"
tarball_url: "https://nowhere.com",
},
engine: { atom: "*" },
semver: "1.0.0",
license: "MIT",
package: "1234",
hasGrammar: false,
hasSnippets: false,
supportedLanguages: null
}
]
supportedLanguages: null,
},
],
};

const parsed = await pof(data);
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/models/constructPackageObjectJSON.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const poj = require("../../../src/models/constructPackageObjectJSON.js");
const schema = require("../../models/packageObjectJSON.js").test;

describe("Parses Data, as expected to be returned by the Database", () => {

test("Correctly Parses normal data", async () => {
const data = {
semver: "1.0.0",
Expand All @@ -12,8 +11,8 @@ describe("Parses Data, as expected to be returned by the Database", () => {
sha: "1234",
name: "package-test",
version: "1.0.0",
tarball_url: "https://nowhere.com"
}
tarball_url: "https://nowhere.com",
},
};

const parsed = await poj(data);
Expand Down
Loading

0 comments on commit 7a2c639

Please sign in to comment.