Skip to content

Commit

Permalink
Merge pull request #14 from scimmyjs/release/1.0.0
Browse files Browse the repository at this point in the history
Release 1.0.0
  • Loading branch information
sleelin authored Nov 15, 2023
2 parents 7f05fac + 8f2fd81 commit 431ce49
Show file tree
Hide file tree
Showing 55 changed files with 6,017 additions and 2,524 deletions.
7 changes: 5 additions & 2 deletions jsdoc.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"plugins": ["plugins/markdown"],
"plugins": [
"plugins/markdown",
"classy-template/plugin"
],
"source": {
"include": ["src"]
},
"opts": {
"recurse": true,
"template": "./node_modules/classy-template",
"template": "classy-template",
"destination": "./docs",
"readme": "./README.md",
"package": "./package.json"
Expand Down
35 changes: 27 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "scimmy",
"description": "SCIMMY - SCIM m(ade eas)y",
"version": "0.10.0",
"version": "1.0.0",
"author": "sleelin",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -37,16 +37,35 @@
"type": "git",
"url": "git+https://github.com/scimmyjs/scimmy.git"
},
"imports": {
"#@/*": {
"default": "./src/*"
}
},
"c8": {
"all": true,
"check-coverage": true,
"include": [
"src/**/*.js"
],
"reporter": [
"clover",
"lcov"
]
},
"bugs": {
"url": "https://github.com/scimmyjs/scimmy/issues"
},
"devDependencies": {
"chalk": "^4.1.2",
"classy-template": "^1.0.2",
"jsdoc": "^3.6.7",
"minimist": "^1.2.5",
"mocha": "^9.1.3",
"rollup": "^2.60.0",
"typescript": "^4.4.4"
"@types/node": "^18.15.11",
"c8": "^7.13.0",
"chalk": "^5.2.0",
"classy-template": "^1.2.0",
"jsdoc": "^4.0.2",
"minimist": "^1.2.8",
"mocha": "^10.2.0",
"rollup": "^3.20.2",
"sinon": "^15.0.3",
"typescript": "^5.0.2"
}
}
35 changes: 23 additions & 12 deletions packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ const basepath = path.relative(process.cwd(), cwd);
export class Packager {
/**
* Various paths to locations of assets used in packaging process
* @type {{src: string, dist: string}}
* @type {{src: string, dist: string, test: string}}
*/
static paths = {
src: `./${path.join(basepath, "src")}`,
dist: `./${path.join(basepath, "dist")}`
dist: `./${path.join(basepath, "dist")}`,
test: `./${path.join(basepath, "test")}`
};

/**
Expand All @@ -40,7 +41,7 @@ export class Packager {

/**
* Create a step function to consistently log action's results
* @param {Boolean} verbose - whether or not to show extended info about action's results
* @param {Boolean} verbose - whether to show extended info about action's results
* @returns {Function} step function
*/
static action(verbose = true) {
Expand Down Expand Up @@ -103,7 +104,7 @@ export class Packager {

/**
* Build the SCIMMY library
* @param {Boolean} [verbose=false] - whether or not to show extended output from each step of the build
* @param {Boolean} [verbose=false] - whether to show extended output from each step of the build
* @returns {Promise<void>} a promise that resolves when the build has completed
*/
static async build(verbose = false) {
Expand Down Expand Up @@ -152,16 +153,24 @@ export class Packager {
*/
static async test(filter, reporter = "base") {
const {default: Mocha} = await import("mocha");
let mocha = new Mocha()
.reporter(...(typeof reporter === "object" ? [reporter.name, reporter.options] : [reporter]))
.addFile(`./${path.join(basepath, "./test/scimmy.js")}`)
.grep(`/${filter ?? ".*"}/i`);
const mocha = new Mocha().reporter(...(typeof reporter === "object" ? [reporter.name, reporter.options] : [reporter]));
// Recursively go through directories and find all test files
const find = async (dir) => (await Promise.all((await fs.readdir(dir, {withFileTypes: true}))
// Put files above directories, then go through and find all files recursively
.sort((fa, fb) => -fa.isFile()+fb.isFile())
.map(async (file) => ([file.isFile() && path.join(dir, file.name), ...(file.isDirectory() ? await find(path.join(dir, file.name)) : [])]))))
// Collapse the pyramid and find all actual test files
.flat(Infinity).filter(filename => !!filename && filename.endsWith(".js"));

// Let mocha know about the test files
for (let file of await find(Packager.paths.test)) mocha.addFile(file);

return new Promise((resolve, reject) => {
mocha.grep(`/^${(filter ?? "").split("").map(s => `[${s}]`).join("") ?? ".*"}/i`);
mocha.timeout("2m").loadFilesAsync().then(() => mocha.run()).then((runner) => {
if (reporter === "base") {
let reporter = new Mocha.reporters.Base(runner),
epilogue = reporter.epilogue.bind(reporter);
const reporter = new Mocha.reporters.Base(runner);
const epilogue = reporter.epilogue.bind(reporter);

runner.on("end", () => !!reporter.stats.failures ? reject(epilogue) : resolve(epilogue));
}
Expand All @@ -186,10 +195,12 @@ export class Packager {
const output = [];
const config = {
exports: "auto",
preferConst: true,
manualChunks: chunks,
minifyInternalExports: false,
hoistTransitiveImports: false,
manualChunks: chunks
generatedCode: {
constBindings: true
}
};

// Prepare RollupJS bundle with supplied entry point
Expand Down
11 changes: 6 additions & 5 deletions src/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const catchAll = () => {throw new TypeError("SCIM Configuration can only be chan
const handleTraps = {set: catchAll, deleteProperty: catchAll, defineProperty: catchAll};

/**
* SCIM Service Provider Configuration Container Class
* SCIMMY Service Provider Configuration Class
* @namespace SCIMMY.Config
* @description
* SCIMMY provides a singleton class, `SCIMMY.Config`, that acts as a central store for a SCIM Service Provider's configuration.
Expand Down Expand Up @@ -122,8 +122,9 @@ export default class Config {
*/
static get() {
// Wrap all the things in a proxy!
return new Proxy(Object.entries(Config.#config)
.reduce((res, [key, value]) => (((res[key] = (key === "documentationUri" ? value : new Proxy(value, handleTraps))) || true) && res), {}), handleTraps);
return new Proxy(Object.entries(Config.#config).reduce((res, [key, value]) => Object.assign(res, {
[key]: (key === "documentationUri" ? value : new Proxy(value, handleTraps))
}), {}), handleTraps);
}

/**
Expand All @@ -132,7 +133,7 @@ export default class Config {
* @param {Object} args - the new configuration to apply to the service provider config instance
* @param {String} args - the name of the configuration property to set
* @param {Object|Boolean} args - the new value of the configuration property to set
* @returns {Object|SCIMMY.Config} the updated configuration instance, or the config container class for chaining
* @returns {Object|typeof SCIMMY.Config} the updated configuration instance, or the config container class for chaining
*/
static set(...args) {
// Dereference name and config from supplied parameters
Expand Down Expand Up @@ -163,7 +164,7 @@ export default class Config {

// Assign documentationUri string
if (!!value) Config.#config.documentationUri = Schemas.ServiceProviderConfig.definition.attribute(key).coerce(value);
else delete Config.#config.documentationUri;
else Config.#config.documentationUri = undefined;
} else if (Array.isArray(target)) {
// Target is multi-valued (authenticationSchemes), add coerced values to config, or reset if empty
if (!value || (Array.isArray(value) && value.length === 0)) target.splice(0);
Expand Down
6 changes: 6 additions & 0 deletions src/lib/messages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import {Error} from "./messages/error.js";
import {ListResponse} from "./messages/listresponse.js";
import {PatchOp} from "./messages/patchop.js";
import {BulkRequest} from "./messages/bulkrequest.js";
import {BulkResponse} from "./messages/bulkresponse.js";
import {SearchRequest} from "./messages/searchrequest.js";

/**
* SCIMMY Messages Container Class
Expand All @@ -13,4 +16,7 @@ export default class Messages {
static Error = Error;
static ListResponse = ListResponse;
static PatchOp = PatchOp;
static BulkRequest = BulkRequest;
static BulkResponse = BulkResponse;
static SearchRequest = SearchRequest;
}
Loading

0 comments on commit 431ce49

Please sign in to comment.