How to use packageName method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

package.js

Source:package.js Github

copy

Full Screen

1sc_require('tasks/task');2// for development3SC.DEBUG_PACKAGES = false;4//...............................................5// Package mode is set globally and allows (mostly for6// development but may serve other purposes) for7// only specific portions of code to be evaluated.8// For instance, if during developement there is a need9// to test only the model layer one would not want to10// include any views or (possibly) control layer objects11// or else it would require loading the entire sproutcore12// framework to run it. Any combination of these settings13// could be used.14SC.PACKAGE_MODE_MODELS = 0x01; 15SC.PACKAGE_MODE_VIEWS = 0x02;16SC.PACKAGE_MODE_CONTROLLERS = 0x04;17// Other is simply mixins/ext/runtime code not otherwise18// categorized that *should* not be dependent on layers19// not otherwise specified to include. Ultimately that20// is the perogative of the developer.21SC.PACKAGE_MODE_OTHER = 0x08;22// The normal mode includes all of the possible flags23SC.PACKAGE_MODE_NORMAL = 0x10;24// The default package flag is set here but can be25// overridden later or by an extended SC.Package class.26SC.PACKAGE_MODE = SC.PACKAGE_MODE_NORMAL;27// To make a combination of other settings do something28// like the following to create the proper bitmask:29// SC.PACKAGE_MODE = SC.PACKAGE_MODE_MODELS | SC.PACKAGE_MODE_OTHER;30/**31 @class32 By default, packages are logically separated containers of code33 built-out by the build tools that can be included in the34 running application in various forms (core, lazy or demand).35 There need only be one package manager for any running36 application as multiples would simply look at the same37 package information. 38 There are global mode settings that can be set to override39 defaults at the application level. Packages can be set40 to evaluate only portions of the source code from the package.41 The buildtools separate content by convention not by inspection.42 Files located in the `models` directory will be included as43 models, `controllers` as controllers and `views` as views. All44 other files (exempting `core.js` that is a specially prioritized45 file) will be included (and ordered) as `other`. The application46 can instruct packages to load combinations of these separated47 layers or all of the (SC.PACKAGE_MODE_NORMAL the default setting).48 It is up to the developer to ensure the files can be programatically49 ordered by their sc_require statements and that files are organized50 in the correct directory structures. If type `other` is selected it51 will be evaluated _before any other types_. This option is52 currently non-configurable.53 @see #SC#PACKAGE_MODE54 @see #SC#PACKAGE_MODE_MODELS55 @see #SC#PACKAGE_MODE_VIEWS56 @see #SC#PACKAGE_MODE_CONTROLLERS'57 @see #SC#PACKAGE_MODE_OTHER58 @see #SC#PACKAGE_MODE_NORMAL59 @see #SC#DEBUG_PACKAGES60 See build-tools documentation for more details @see#BT#Package61 @author W. Cole Davis62 @author Original author(s) of SC.Module63*/64SC.Package = SC.Object.extend(65 /** @lends SC.Package.prototype */ {66 /** @private */67 log: SC.DEBUG_PACKAGES,68 /**69 Attempt to load a package. If it has been loaded but not evaluated will be70 evaluated. If already loaded and evaluated but a new callback is supplied it71 will be executed immediately (along with any other queued callbacks). Callbacks72 will always be supplied with the first parameter as the name of the package73 that was loaded and that is invoking it.74 @param {String} packageName The name of the package to load.75 @param {Object} [target] The context from which to call the callback method.76 @param {Function} [method] The function to execute as the callback.77 @param {...} [args] Any additional arguments will be supplied to the78 callback as paramters.79 */80 loadPackage: function(packageName, target, method) {81 var package = SC.PACKAGE_MANIFEST[packageName];82 var args = SC.A(arguments).slice(3);83 var log = this.log;84 if (method === undefined && target instanceof Function) {85 method = target;86 target = null;87 }88 if (!package) {89 throw "SC.Package: could not find package '%@'".fmt(packageName);90 }91 if (package.isReady) {92 if (log) SC.Logger.info("loadPackage() package '%@' already loaded and ready".fmt(packageName));93 this.registerCallbackForPackage(packageName, target, method, args);94 this._sc_invokeCallbacksForPackage(packageName);95 return true;96 } else if (package.isLoaded && !package.isWaitingForRunloop) {97 if (log) SC.Logger.info("loadPackage() package '%@' was loaded and ".fmt(packageName) +98 "was not waiting for runloop");99 if (!this._sc_dependenciesMetForPackage(packageName)) {100 if (log) SC.Logger.info("loadPackage() package dependencies were not met for " +101 "package '%@'".fmt(packageName));102 this.registerCallbackForPackage(packageName, target, method, args);103 this._sc_loadDependenciesForPackage(packageName);104 return false;105 }106 if (package.source) {107 if (log) SC.Logger.info("loadPackage() package '%@' source is available and will ".fmt(packageName) +108 "be executed now");109 this._sc_evaluatePackageSource(packageName);110 this.registerCallbackForPackage(packageName, target, method, args);111 this.invokeLast(function() {112 package.isReady = true;113 this._sc_packageDidBecomeReady(packageName);114 });115 return false;116 }117 } else if (package.isWaitingForRunLoop) {118 this.registerCallbackForPackage(packageName, target, method, args);119 return true;120 } else {121 this.registerCallbackForPackage(packageName, target, method, args);122 if (!package.isLoading) {123 if (log) SC.Logger.info("loadPackage() package '%@' loading dependencies and ".fmt(packageName) +124 "source");125 this._sc_loadDependenciesForPackage(packageName);126 this.loadJavaScriptForPackage(packageName);127 package.isLoading = true;128 }129 return false;130 }131 },132 /**133 Load all available packages.134 135 @method136 */137 loadAll: function() {138 var packageName;139 var package;140 for (packageName in SC.PACKAGE_MANIFEST) {141 package = SC.PACKAGE_MANIFEST[packageName];142 if (!package.isLoading && !package.isLoaded && !package.isReady) {143 this.loadPackage(packageName);144 }145 }146 },147 /**148 Register a callback method to be called once the package has successfully149 loaded and been evaluated. Additional arguments will be applied as150 arguments to the callback when it is executed.151 @param {String} packageName The name of the package for which to152 register the callback.153 @param {Object} [target] The context for which to run the callback method.154 @param {Function} [method] The callback function to execute.155 @param {...} [args] Any other arguments will be used as parameters to the callback. 156 */157 registerCallbackForPackage: function(packageName, target, method, args) {158 var package = SC.PACKAGE_MANIFEST[packageName];159 var cb;160 if (!args) args = [];161 args.unshift(packageName);162 if (target) {163 if (target instanceof Function) {164 method = target;165 target = null;166 }167 } else { return; }168 if (typeof method === 'string') {169 method = target[method];170 }171 cb = function() {172 var needsRunLoop = !!SC.RunLoop.currentRunloop;173 if (needsRunLoop) {174 SC.run(function() {175 method.apply(target, args);176 });177 } else {178 method.apply(target, args);179 }180 }181 if (!package.callbacks) {182 package.callbacks = [];183 }184 package.callbacks.push(cb);185 },186 /**187 Attempt to retrieve the source JavaScript for a188 package from the webserver. This method can be189 overridden in extensions of SC.Package to190 retrieve the source by some other means. 191 @param {String} packageName The name of the requested192 package to retrieve.193 @returns {SC.Package} receiver194 */195 loadJavaScriptForPackage: function(packageName) {196 var package = SC.PACKAGE_MANIFEST[packageName];197 var log = this.log; 198 var el;199 var url = this._sc_urlForPackage(packageName);200 var self = this;201 if (package.isLoaded) {202 if (log) SC.Logger.warn("loadJavaScript() package '%@' already loaded".fmt(packageName));203 return;204 }205 // set the isLoading flag to true206 package.isLoading = true;207 // create the script element that will generate the208 // request for the source209 el = document.createElement('script');210 el.setAttribute('type', 'text/javascript');211 el.setAttribute('src', url);212 213 // needs to be tested with various versions of IE to determine214 // if this will work215 el.onload = function() {216 SC.run(function() {217 // we don't know who is handling this thus218 // the scoping back to self219 self._sc_packageDidLoad(packageName);220 });221 }222 // go ahead and add the node to the dom so223 // the request will be made...224 document.body.appendChild(el);225 return this;226 },227 /**228 Creates the url for the script to request when loading229 the JavaScript source of packages.230 @param {String} packageName The name of the package being231 requested.232 @returns {String} The constructed url or null if it could233 not be built or determined.234 */235 _sc_urlForPackage: function(packageName) {236 var package = SC.PACKAGE_MANIFEST[packageName];237 var mask = SC.PACKAGE_MODE;238 var url = [];239 url.push(package.rootNode);240 url.push('packages');241 url.push(package.basename);242 url = '/' + url.join('/'); 243 return url;244 },245 /**246 Determines if all of the dependencies for a package have247 been loaded and executed.248 @param {String} packageName The name of the package whose249 dependencies are being evaluated.250 @returns {Boolean} YES|NO depending on whether all of the251 dependencies have been met.252 */253 _sc_dependenciesMetForPackage: function(packageName) {254 var package = SC.PACKAGE_MANIFEST[packageName];255 var dependencies = package.dependencies || [];256 var dependency;257 var name;258 var idx = 0;259 for (; idx < dependencies.length; ++idx) {260 name = dependencies[idx];261 dependency = SC.PACKAGE_MANIFEST[name];262 263 if (!dependency) {264 throw "SC.Package: could not find dependency '%@' for package ".fmt(name) +265 "'%@'".fmt(packageName);266 }267 268 if (!dependency.isReady) return false;269 }270 return true;271 },272 273 /**274 Find and load any dependencies for a given package.275 @param {String} packageName The target package.276 */277 _sc_loadDependenciesForPackage: function(packageName) {278 var package = SC.PACKAGE_MANIFEST[packageName];279 var log = this.log;280 var dependencies = package.dependencies || [];281 var dependency;282 var name;283 var dependents;284 var idx = 0;285 if (log) SC.Logger.info("_sc_loadDependenciesForPackage() loading dependencies " +286 "for package '%@'".fmt(packageName));287 for (; idx < dependencies.length; ++idx) {288 name = dependencies[idx];289 dependency = SC.PACKAGE_MANIFEST[name];290 if (!dependency) {291 throw "SC.Package: could not find dependency '%@' for package ".fmt(name) +292 "'%@'".fmt(packageName);293 } else {294 if (dependency.isLoading) {295 dependents = dependency.dependents;296 if (!dependents) dependency.dependents = dependents = [];297 dependents.push(packageName);298 } else if (dependency.isReady) {299 continue;300 } else {301 dependents = dependency.dependents;302 if (!dependents) dependency.dependents = dependents = [];303 dependents.push(packageName);304 if (log) SC.Logger.info("_sc_loadDependenciesForPackage() package '%@' ".fmt(packageName) +305 "requires loading '%@'".fmt(name));306 this.loadPackage(name);307 }308 }309 }310 },311 /**312 Called once a package's source is loaded and ready.313 @param {String} packageName The name of the package that314 was loaded.315 */316 _sc_packageDidLoad: function(packageName) {317 var package = SC.PACKAGE_MANIFEST[packageName];318 var log = this.log;319 if (log) SC.Logger.info("_sc_packageDidLoad() package '%@' loaded".fmt(packageName));320 delete package.isLoading;321 package.isLoaded = true;322 if (!this._sc_dependenciesMetForPackage(packageName)) {323 if (log) SC.Logger.info("_sc_packageDidLoad() package '%@' still waiting on ".fmt(packageName) +324 "some dependencies to load");325 } else if (package.source) {326 this._sc_evaluatePackageSource(packageName);327 package.isWaitingForRunLoop = true;328 this.invokeLast(function() {329 package.isReady = true;330 this._sc_packageDidBecomeReady(packageName);331 });332 } else {333 throw "SC.Package: package '%@' was loaded without any source".fmt(packageName);334 }335 },336 /**337 Attempts to notify any waiting dependent packages that this338 dependency is now available. If the dependent is now ready it is339 executed.340 341 @param {String} packageName The name of the package that became ready.342 */343 _sc_packageDidBecomeReady: function(packageName) {344 var package = SC.PACKAGE_MANIFEST[packageName];345 var dependents = package.dependents || [];346 var idx = 0;347 var dependent;348 var name;349 var log = this.log;350 if (log) SC.Logger.info("_sc_packageDidBecomeReady() invoking callbacks and " +351 "evaluating dependents for package '%@'".fmt(packageName));352 package.isWaitingForRunLoop = false;353 this._sc_invokeCallbacksForPackage(packageName);354 for (; idx < dependents.length; ++idx) {355 name = dependents[idx];356 dependent = SC.PACKAGE_MANIFEST[name];357 if (dependent.isLoaded && this._sc_dependenciesMetForPackage(name)) {358 if (log) SC.Logger.info("_sc_packageDidBecomeReady() package '%@' dependent ".fmt(packageName) +359 "'%@' is ready to be executed now".fmt(name));360 this._sc_evaluatePackageSource(name); 361 dependent.isWaitingForRunLoop = true;362 this.invokeLast(function() {363 dependent.isReady = true;364 this._sc_packageDidBecomeReady(name);365 });366 }367 }368 },369 /**370 Retrieves any available callbacks for the named package371 and executes them in the order they were entered in the372 queue. Callbacks are freed once they have been executed.373 @param {String} packageName The name of the package whose374 callbacks need to be executed.375 */376 _sc_invokeCallbacksForPackage: function(packageName) {377 var package = SC.PACKAGE_MANIFEST[packageName];378 var callbacks = package.callbacks || [];379 var idx = 0;380 var callback;381 for (; idx < callbacks.length; ++idx) {382 callback = callbacks[idx];383 callback();384 }385 },386 /**387 Evaluates the source or portion of the loaded source for388 a given package.389 @param {String} packageName The name of the package from which390 to evaluate source code.391 */392 _sc_evaluatePackageSource: function(packageName) {393 var package = SC.PACKAGE_MANIFEST[packageName];394 var flags = SC.PACKAGE_MODE;395 var log = this.log;396 var source;397 var code;398 var parts = [];399 var part;400 var idx = 0;401 if (package.isEvaluated) {402 return;403 }404 if (log) SC.Logger.info("_sc_evaluatePackageSource() attempting to " +405 "execute source for package '%@'".fmt(packageName));406 // if there is no source we can't do much either407 if (!package.source) {408 throw "SC.Package: cannot execute non-existant source for package '%@'".fmt(packageName);409 }410 source = package.source;411 // the ordering of inclusion is important here412 if (flags & SC.PACKAGE_MODE_NORMAL) {413 parts = "other models controllers views".w();414 } else {415 if (flags & SC.PACKAGE_MODE_OTHER) {416 parts.push('other');417 }418 if (flags & SC.PACKAGE_MODE_MODELS) {419 parts.push('models');420 }421 if (flags & SC.PACKAGE_MODE_CONTROLLERS) {422 parts.push('controllers');423 }424 if (flags & SC.PACKAGE_MODE_VIEWS) {425 parts.push('views');426 }427 }428 code = '';429 for (; idx < parts.length; ++idx) {430 part = parts[idx];431 if (source[part]) {432 if (code && code.length > 0) code += ';';433 code += source[part];434 // free the used element of the source from435 // the package source object436 delete package.source[part];437 }438 }439 // if we accumulated any code go ahead and execute it440 if (code && code.length > 0) {441 442 try {443 // need to execute in the global scope and444 // make up for msie shortcomings445 (window.execScript || function(data) {446 window['eval'].call(window, data);447 })(code);448 package.isEvaluated = true;449 } catch(err) {450 throw "SC.Package: failed to evaluate source for package '%@' ".fmt(packageName) +451 "due to the following error: " + err.message;452 }453 } else {454 if (log) SC.Logger.warn("_sc_evaluatePackageSource() " +455 "no package source found for given package mode for package '%@'".fmt(packageName));456 }457 package.isReady = true;458 },459 /** @private */460 init: function() {461 arguments.callee.base.apply(this, arguments);462 var self = this;463 // update the task definition to use the correct464 // package manager465 SC.Package.LazyPackageTask.prototype.run = function() {466 self.loadPackage(this.lazyPackageName);467 }468 SC.ready(function() {469 var packages = SC.PACKAGE_MANIFEST;470 var package;471 var task;472 473 for (packageName in packages) {474 package = packages[packageName];475 476 if (package.type === 'lazy') {477 task = SC.Package.LazyPackageTask.create({ lazyPackageName: packageName });478 SC.backgroundTaskQueue.push(task);479 }480 }481 });482 } // init483});484SC.Package.LazyPackageTask = SC.Task.extend({485 lazyPackageName: null,...

Full Screen

Full Screen

packageExtra.js

Source:packageExtra.js Github

copy

Full Screen

1/* Store extra package data to Redis.2 *3 * pkg:$pkgname4 * invalidTags: JSON array5 * stars: int6 * unity: string7 */8const config = require("config");9const redis = require("../db/redis");10const { getImage } = require("../utils/media");11const { loadPackage } = require("../utils/package");12const allPackagesExtraKey = "pkgs:extra";13const recentPackagesKey = "pkgs:recent";14const packageKey = "pkg:";15const propKeys = {16 imageUrl: "imageUrl",17 invalidTags: "invalidTags",18 parentStars: "pstars",19 readme: "readme",20 readmeHtml: "readmeHtml",21 readme_zhCN: "readme_zhCN",22 readmeHtml_zhCN: "readmeHtml_zhCN",23 scopes: "scopes",24 stars: "stars",25 unityVersion: "unity",26 updatedTime: "updatedTime",27 repoPushedTime: "repoPushedTime",28 repoUnavailable: "repoUnavailable",29 version: "ver"30};31const setInvalidTags = async function(packageName, tags) {32 const jsonText = JSON.stringify(tags, null, 0);33 await setValue(packageName, propKeys.invalidTags, jsonText);34};35const getInvalidTags = async function(packageName) {36 const jsonText = await getValue(packageName, propKeys.invalidTags);37 return jsonText === null ? [] : JSON.parse(jsonText);38};39const setScopes = async function(packageName, scopes) {40 const jsonText = JSON.stringify(scopes, null, 0);41 await setValue(packageName, propKeys.scopes, jsonText);42};43const getScopes = async function(packageName) {44 const jsonText = await getValue(packageName, propKeys.scopes);45 return jsonText === null ? [] : JSON.parse(jsonText);46};47const setVersion = async function(packageName, version) {48 await setValue(packageName, propKeys.version, version);49};50const getVersion = async function(packageName) {51 const text = await getValue(packageName, propKeys.version);52 return text;53};54const setUnityVersion = async function(packageName, unityVersion) {55 await setValue(packageName, propKeys.unityVersion, unityVersion);56};57const getUnityVersion = async function(packageName) {58 const text = await getValue(packageName, propKeys.unityVersion);59 return text;60};61const setStars = async function(packageName, stars) {62 await setValue(packageName, propKeys.stars, stars);63};64const getStars = async function(packageName) {65 const text = await getValue(packageName, propKeys.stars);66 return parseInt(text);67};68const setParentStars = async function(packageName, stars) {69 await setValue(packageName, propKeys.parentStars, stars);70};71const getParentStars = async function(packageName) {72 const text = await getValue(packageName, propKeys.parentStars);73 return parseInt(text);74};75const setReadme = async function(packageName, readme, lang) {76 const key = lang == "zh-CN" ? propKeys.readme_zhCN : propKeys.readme;77 await setValue(packageName, key, readme);78};79const getReadme = async function(packageName, lang) {80 const key = lang == "zh-CN" ? propKeys.readme_zhCN : propKeys.readme;81 const text = await getValue(packageName, key);82 return text;83};84const setReadmeHtml = async function(packageName, readmeHtml, lang) {85 const key = lang == "zh-CN" ? propKeys.readmeHtml_zhCN : propKeys.readmeHtml;86 await setValue(packageName, key, readmeHtml);87};88const getReadmeHtml = async function(packageName, lang) {89 const key = lang == "zh-CN" ? propKeys.readmeHtml_zhCN : propKeys.readmeHtml;90 const text = await getValue(packageName, key);91 return text;92};93const setImageUrl = async function(packageName, imageUrl) {94 await setValue(packageName, propKeys.imageUrl, imageUrl);95};96const getImageUrl = async function(packageName) {97 const text = await getValue(packageName, propKeys.imageUrl);98 return text;99};100/**101 * Get image query data for a package, return { imageUrl, width, height, fit }102 * @param {string} packageName103 */104const getImageQueryForPackage = async function(packageName) {105 // get the image url106 const pkg = await loadPackage(packageName);107 let imageUrl = await getImageUrl(packageName);108 if (!imageUrl) {109 imageUrl = pkg.image;110 }111 if (!imageUrl) return null;112 const width = config.packageExtra.image.width;113 const height = config.packageExtra.image.height;114 const fit = pkg.imageFit == "contain" ? "contain" : "cover";115 return { imageUrl, width, height, fit };116};117/**118 * Get image query data for a GitHub user, return { imageUrl, width, height, fit }119 * @param {string} username120 * @param {Number} size121 */122const getImageQueryForGithubUser = async function(username, size) {123 // get the image url124 const imageUrl = `https://github.com/${username}.png?size=${size}`;125 return { imageUrl, width: size, height: size, fit: "cover" };126};127/**128 * Get the cached image filename129 * @param {string} packageName130 */131const getCachedImageFilename = async function(packageName) {132 const imageQuery = await getImageQueryForPackage(packageName);133 if (imageQuery) {134 const imageData = await getImage(imageQuery);135 if (imageData) return imageData.filename;136 }137 return null;138};139const setRepoPushedTime = async function(packageName, value) {140 await setValue(packageName, propKeys.repoPushedTime, value);141};142const getRepoPushedTime = async function(packageName) {143 const value = await getValue(packageName, propKeys.repoPushedTime);144 return parseInt(value);145};146const setRepoUnavailable = async function(packageName, value) {147 await setValue(packageName, propKeys.repoUnavailable, value ? "1" : "0");148};149const getRepoUnavailable = async function(packageName) {150 const text = await getValue(packageName, propKeys.repoUnavailable);151 return text == "1" ? true : false;152};153const setUpdatedTime = async function(packageName, updatedTime) {154 await setValue(packageName, propKeys.updatedTime, updatedTime);155};156const getUpdatedTime = async function(packageName) {157 const value = await getValue(packageName, propKeys.updatedTime);158 return parseInt(value);159};160const setValue = async function(packageName, propKey, propVal) {161 const key = packageKey + packageName;162 await redis.client.hset(key, propKey, propVal);163};164const getValue = async function(packageName, propKey) {165 const key = packageKey + packageName;166 return await redis.client.hget(key, propKey);167};168/**169 * Set aggregated extra data.170 * @param {object} obj171 */172const setAggregatedExtraData = async function(obj) {173 const jsonText = JSON.stringify(obj, null, 0);174 await redis.client.set(allPackagesExtraKey, jsonText);175};176/**177 * Get aggregated extra data.178 */179const getAggregatedExtraData = async function() {180 const jsonText = await redis.client.get(allPackagesExtraKey);181 return jsonText === null ? {} : JSON.parse(jsonText);182};183/**184 * Set recent packages.185 * @param {object} obj186 */187const setRecentPackages = async function(arr) {188 const jsonText = JSON.stringify(arr, null, 0);189 await redis.client.set(recentPackagesKey, jsonText);190};191/**192 * Get recent packages.193 */194const getRecentPackages = async function() {195 const jsonText = await redis.client.get(recentPackagesKey);196 return jsonText === null ? [] : JSON.parse(jsonText);197};198module.exports = {199 getAggregatedExtraData,200 getCachedImageFilename,201 getImageQueryForGithubUser,202 getImageQueryForPackage,203 getImageUrl,204 getInvalidTags,205 getParentStars,206 getReadme,207 getReadmeHtml,208 getRecentPackages,209 getRepoPushedTime,210 getRepoUnavailable,211 getScopes,212 getStars,213 getUnityVersion,214 getUpdatedTime,215 getVersion,216 setAggregatedExtraData,217 setImageUrl,218 setInvalidTags,219 setParentStars,220 setReadme,221 setReadmeHtml,222 setRecentPackages,223 setRepoPushedTime,224 setRepoUnavailable,225 setScopes,226 setStars,227 setUnityVersion,228 setUpdatedTime,229 setVersion...

Full Screen

Full Screen

package.ts

Source:package.ts Github

copy

Full Screen

1/*2 * @license3 * Copyright Akveo. All Rights Reserved.4 * Licensed under the MIT License. See License.txt in the project root for license information.5 */6import { Tree } from '@angular-devkit/schematics';7import { readJSON, writeJSON } from './file';8const packageJsonName = 'package.json';9interface PackageJson {10 version: string;11 dependencies: { [key: string]: string },12 devDependencies: { [key: string]: string },13 peerDependencies: { [key: string]: string },14}15export function getNebularVersion(): string {16 return getNebularPackageJson().version;17}18/**19 * Gets the version of the specified Nebular peerDependency20 * */21export function getNebularPeerDependencyVersionFromPackageJson(packageName: string): string {22 const packageJson: PackageJson = getNebularPackageJson();23 if (noInfoAboutPeerDependency(packageJson, packageName)) {24 throwNoPackageInfoInPackageJson(packageName);25 }26 return packageJson.peerDependencies[packageName];27}28/**29 * Eva Icons version30 * */31export function getEvaIconsVersion(): string {32 const packageJson: PackageJson = getNebularEvaIconsPackageJson();33 const packageName = 'eva-icons';34 if (noInfoAboutPeerDependency(packageJson, packageName)) {35 throwNoPackageInfoInPackageJson(packageName);36 }37 return packageJson.peerDependencies[packageName];38}39/**40 * Gets the version of the specified dependency by looking at the package.json in the specified tree41 * */42export function getDependencyVersionFromPackageJson(tree: Tree, packageName: string): string {43 if (!tree.exists(packageJsonName)) {44 throwNoPackageJsonError();45 }46 const packageJson: PackageJson = readJSON(tree, packageJsonName);47 if (noInfoAboutDependency(packageJson, packageName)) {48 throwNoPackageInfoInPackageJson(packageName);49 }50 return packageJson.dependencies[packageName];51}52export function addDependencyToPackageJson(tree: Tree, packageName: string, packageVersion: string, force = false) {53 if (!tree.exists(packageJsonName)) {54 throwNoPackageJsonError();55 }56 const packageJson: PackageJson = readJSON(tree, packageJsonName);57 if (!packageJson.dependencies) {58 packageJson.dependencies = {};59 }60 if (!packageJson.dependencies[packageName] || force) {61 packageJson.dependencies[packageName] = packageVersion;62 packageJson.dependencies = sortObjectByKeys(packageJson.dependencies);63 }64 writeJSON(tree, packageJsonName, packageJson);65}66/**67 * Gets the version of the specified dev dependency by looking at the package.json in the specified tree68 * */69export function getDevDependencyVersionFromPackageJson(tree: Tree, packageName: string): string {70 if (!tree.exists(packageJsonName)) {71 throwNoPackageJsonError();72 }73 const packageJson: PackageJson = readJSON(tree, packageJsonName);74 if (noInfoAboutDevDependency(packageJson, packageName)) {75 throwNoPackageInfoInPackageJson(packageName);76 }77 return packageJson.devDependencies[packageName];78}79export function addDevDependencyToPackageJson(tree: Tree, packageName: string, packageVersion: string) {80 if (!tree.exists(packageJsonName)) {81 throwNoPackageJsonError();82 }83 const packageJson: PackageJson = readJSON(tree, packageJsonName);84 if (!packageJson.devDependencies) {85 packageJson.devDependencies = {};86 }87 if (!packageJson.devDependencies[packageName]) {88 packageJson.devDependencies[packageName] = packageVersion;89 packageJson.devDependencies = sortObjectByKeys(packageJson.devDependencies);90 }91 writeJSON(tree, packageJsonName, packageJson);92}93function throwNoPackageJsonError() {94 throw new Error('No package.json found in the tree.');95}96function throwNoPackageInfoInPackageJson(packageName: string) {97 throw new Error(`No info found in package.json for ${packageName}`);98}99/**100 * Validates packageJson has dependencies, also as specified dependency not exists.101 * */102function noInfoAboutDependency(packageJson: PackageJson, packageName: string): boolean {103 return !dependencyAlreadyExists(packageJson, packageName);104}105/**106 * Validates packageJson has devDependencies, also as specified devDependency not exists.107 * */108function noInfoAboutDevDependency(packageJson: PackageJson, packageName: string): boolean {109 return !devDependencyAlreadyExists(packageJson, packageName);110}111/**112 * Validates packageJson has peerDependencies, also as specified peerDependency not exists.113 * */114function noInfoAboutPeerDependency(packageJson: PackageJson, packageName: string): boolean {115 return !peerDependencyAlreadyExists(packageJson, packageName);116}117/**118 * Validates packageJson has dependencies, also as specified dependency exists.119 * */120function dependencyAlreadyExists(packageJson: PackageJson, packageName: string): boolean {121 return !!(packageJson.dependencies && packageJson.dependencies[packageName]);122}123/**124 * Validates packageJson has devDependencies, also as specified devDependency exists.125 * */126function devDependencyAlreadyExists(packageJson: PackageJson, packageName: string): boolean {127 return !!(packageJson.devDependencies && packageJson.devDependencies[packageName]);128}129/**130 * Validates packageJson has peerDependencies, also as specified peerDependency exists.131 * */132function peerDependencyAlreadyExists(packageJson: PackageJson, packageName: string): boolean {133 return !!(packageJson.peerDependencies && packageJson.peerDependencies[packageName]);134}135/**136 * Sorts the keys of the given object.137 * @returns A new object instance with sorted keys138 */139function sortObjectByKeys(obj: object) {140 return Object.keys(obj).sort().reduce((result, key) => (result[key] = obj[key]) && result, {});141}142function getNebularPackageJson(): PackageJson {143 return require('../../package.json');144}145function getNebularEvaIconsPackageJson(): PackageJson {146 return require('../../../eva-icons/package.json');...

Full Screen

Full Screen

gapi.client.androidpublisher-tests.ts

Source:gapi.client.androidpublisher-tests.ts Github

copy

Full Screen

1/* This is stub file for gapi.client.{{=it.name}} definition tests */2/* IMPORTANT.3* This file was automatically generated by https://github.com/Bolisov/google-api-typings-generator. Please do not edit it manually.4* In case of any problems please post issue to https://github.com/Bolisov/google-api-typings-generator5**/6gapi.load('client', () => {7 /** now we can use gapi.client */8 gapi.client.load('androidpublisher', 'v2', () => {9 /** now we can use gapi.client.androidpublisher */10 /** don't forget to authenticate your client before sending any request to resources: */11 /** declare client_id registered in Google Developers Console */12 const client_id = '<<PUT YOUR CLIENT ID HERE>>';13 const scope = [14 /** View and manage your Google Play Developer account */15 'https://www.googleapis.com/auth/androidpublisher',16 ];17 const immediate = true;18 gapi.auth.authorize({ client_id, scope, immediate }, authResult => {19 if (authResult && !authResult.error) {20 /** handle succesfull authorization */21 run();22 } else {23 /** handle authorization error */24 }25 });26 run();27 });28 async function run() {29 /** Commits/applies the changes made in this edit back to the app. */30 await gapi.client.edits.commit({31 editId: "editId",32 packageName: "packageName",33 });34 /**35 * Deletes an edit for an app. Creating a new edit will automatically delete any of your previous edits so this method need only be called if you want to36 * preemptively abandon an edit.37 */38 await gapi.client.edits.delete({39 editId: "editId",40 packageName: "packageName",41 });42 /** Returns information about the edit specified. Calls will fail if the edit is no long active (e.g. has been deleted, superseded or expired). */43 await gapi.client.edits.get({44 editId: "editId",45 packageName: "packageName",46 });47 /** Creates a new edit for an app, populated with the app's current state. */48 await gapi.client.edits.insert({49 packageName: "packageName",50 });51 /** Checks that the edit can be successfully committed. The edit's changes are not applied to the live app. */52 await gapi.client.edits.validate({53 editId: "editId",54 packageName: "packageName",55 });56 /** Lists the user's current inapp item or subscription entitlements */57 await gapi.client.entitlements.list({58 maxResults: 1,59 packageName: "packageName",60 productId: "productId",61 startIndex: 4,62 token: "token",63 });64 await gapi.client.inappproducts.batch({65 });66 /** Delete an in-app product for an app. */67 await gapi.client.inappproducts.delete({68 packageName: "packageName",69 sku: "sku",70 });71 /** Returns information about the in-app product specified. */72 await gapi.client.inappproducts.get({73 packageName: "packageName",74 sku: "sku",75 });76 /** Creates a new in-app product for an app. */77 await gapi.client.inappproducts.insert({78 autoConvertMissingPrices: true,79 packageName: "packageName",80 });81 /** List all the in-app products for an Android app, both subscriptions and managed in-app products.. */82 await gapi.client.inappproducts.list({83 maxResults: 1,84 packageName: "packageName",85 startIndex: 3,86 token: "token",87 });88 /** Updates the details of an in-app product. This method supports patch semantics. */89 await gapi.client.inappproducts.patch({90 autoConvertMissingPrices: true,91 packageName: "packageName",92 sku: "sku",93 });94 /** Updates the details of an in-app product. */95 await gapi.client.inappproducts.update({96 autoConvertMissingPrices: true,97 packageName: "packageName",98 sku: "sku",99 });100 /** Returns a single review. */101 await gapi.client.reviews.get({102 packageName: "packageName",103 reviewId: "reviewId",104 translationLanguage: "translationLanguage",105 });106 /** Returns a list of reviews. Only reviews from last week will be returned. */107 await gapi.client.reviews.list({108 maxResults: 1,109 packageName: "packageName",110 startIndex: 3,111 token: "token",112 translationLanguage: "translationLanguage",113 });114 /** Reply to a single review, or update an existing reply. */115 await gapi.client.reviews.reply({116 packageName: "packageName",117 reviewId: "reviewId",118 });119 }...

Full Screen

Full Screen

getPackageWebpackConfig.js

Source:getPackageWebpackConfig.js Github

copy

Full Screen

1var MiniCssExtractPlugin = require('mini-css-extract-plugin');2var OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');3var CompressionPlugin = require('compression-webpack-plugin');4var path = require('path');5var getBabelConfig = require('./getBabelConfig');6var OUTPUT_DIR = './dist';7const packages = {8 '@cassette/core': {9 library: 'cassetteCore',10 file: 'cassette-core'11 },12 '@cassette/components': {13 library: 'cassetteComponents',14 file: 'cassette-components'15 },16 '@cassette/player': {17 library: 'cassettePlayer',18 file: 'cassette-player'19 },20 '@cassette/hooks': {21 library: 'cassetteHooks',22 file: 'cassette-hooks'23 }24};25const externals = {26 'prop-types': {27 root: 'PropTypes',28 commonjs: 'prop-types',29 commonjs2: 'prop-types',30 amd: 'prop-types'31 },32 react: {33 root: 'React',34 commonjs: 'react',35 commonjs2: 'react',36 amd: 'react'37 },38 'resize-observer-polyfill': {39 root: 'ResizeObserver',40 commonjs: 'resize-observer-polyfill',41 commonjs2: 'resize-observer-polyfill',42 amd: 'resize-observer-polyfill'43 }44};45for (const packageName of Object.keys(packages)) {46 externals[packageName] = {47 root: packages[packageName].library,48 commonjs: packageName,49 commonjs2: packageName,50 amd: packageName51 };52}53const styleLoaders = [54 {55 test: /\.css$/,56 use: [MiniCssExtractPlugin.loader, 'css-loader']57 },58 {59 test: /\.scss$/,60 use: [61 MiniCssExtractPlugin.loader,62 'css-loader',63 'postcss-loader',64 'sass-loader'65 ]66 }67];68const stylePlugins = [69 new MiniCssExtractPlugin({70 filename: 'css/[name].css',71 path: path.join(process.cwd(), OUTPUT_DIR, 'css')72 }),73 new OptimizeCSSAssetsPlugin({74 assetNameRegExp: /\.min\.css$/75 })76];77function webpackConfig({78 esmodules,79 minimize,80 hasStyles,81 packageName,82 entrySrc83}) {84 return {85 mode: process.env.WEBPACK_SERVE ? 'development' : 'production',86 entry: {87 [minimize88 ? `${packages[packageName].file}.min`89 : packages[packageName].file]: entrySrc90 },91 resolve: {92 extensions: ['.js', '.jsx']93 },94 output: {95 path: path.join(process.cwd(), OUTPUT_DIR),96 publicPath: '/dist',97 libraryTarget: 'umd',98 library: packages[packageName].library,99 filename: `${esmodules ? 'esm/' : 'es5/'}[name].js`,100 globalObject: '(typeof self !== "undefined" ? self : this)'101 },102 module: {103 rules: [104 ...(hasStyles ? styleLoaders : []),105 {106 test: /\.jsx?$/,107 exclude: /node_modules/,108 use: {109 loader: 'babel-loader',110 options: getBabelConfig(esmodules, minimize)111 }112 }113 ]114 },115 externals,116 devtool: 'source-map',117 plugins: [...(hasStyles ? stylePlugins : []), new CompressionPlugin()],118 optimization: {119 noEmitOnErrors: true,120 minimize121 }122 };123}124function getPackageWebpackConfig({ packageName, hasStyles, entrySrc }) {125 switch (process.env.BUILD_MODE) {126 case 'minimize':127 return [128 webpackConfig({129 esmodules: true,130 minimize: true,131 hasStyles,132 packageName,133 entrySrc134 }),135 webpackConfig({136 esmodules: false,137 minimize: true,138 hasStyles,139 packageName,140 entrySrc141 })142 ];143 case 'unminimized':144 return [145 webpackConfig({146 esmodules: true,147 minimize: false,148 hasStyles,149 packageName,150 entrySrc151 }),152 webpackConfig({153 esmodules: false,154 minimize: false,155 hasStyles,156 packageName,157 entrySrc158 })159 ];160 case 'all':161 default:162 return [163 webpackConfig({164 esmodules: true,165 minimize: true,166 hasStyles,167 packageName,168 entrySrc169 }),170 webpackConfig({171 esmodules: false,172 minimize: true,173 hasStyles,174 packageName,175 entrySrc176 }),177 webpackConfig({178 esmodules: true,179 minimize: false,180 hasStyles,181 packageName,182 entrySrc183 }),184 webpackConfig({185 esmodules: false,186 minimize: false,187 hasStyles,188 packageName,189 entrySrc190 })191 ];192 }193}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { packageName } = require('fast-check-monorepo');2console.log(packageName());3const { packageName } = require('fast-check-monorepo');4console.log(packageName());5const { packageName } = require('fast-check-monorepo');6console.log(packageName());7const { packageName } = require('fast-check-monorepo');8console.log(packageName());9const { packageName } = require('fast-check-monorepo');10console.log(packageName());11const { packageName } = require('fast-check-monorepo');12console.log(packageName());13const { packageName } = require('fast-check-monorepo');14console.log(packageName());15const { packageName } = require('fast-check-monorepo');16console.log(packageName());17const { packageName } = require('fast-check-monorepo');18console.log(packageName());19const { packageName } = require('fast-check-monorepo');20console.log(packageName());21const { packageName } = require('fast-check-monorepo');22console.log(packageName());23const { packageName } = require('fast-check-monorepo');24console.log(packageName());25const { packageName } = require('fast-check-monorepo');26console.log(packageName());27const { packageName }

Full Screen

Using AI Code Generation

copy

Full Screen

1const { packageName } = require('fast-check-monorepo');2console.log(packageName());3const { packageName } = require('fast-check-monorepo');4console.log(packageName());5const { packageName } = require('fast-check-monorepo');6console.log(packageName());

Full Screen

Using AI Code Generation

copy

Full Screen

1import packageName from 'fast-check-monorepo'2console.log(packageName())3{4 "dependencies": {5 }6}

Full Screen

Using AI Code Generation

copy

Full Screen

1const packageName = require('fast-check-monorepo/package-name');2console.log(packageName());3const packageName = require('fast-check/package-name');4console.log(packageName());5const packageName = require('fast-check-monorepo/package-name');6console.log(packageName());7const packageName = require('fast-check/package-name');8console.log(packageName());9const packageName = require('fast-check-monorepo/package-name');10console.log(packageName());11const packageName = require('fast-check/package-name');12console.log(packageName());13const packageName = require('fast-check-monorepo/package-name');14console.log(packageName());15const packageName = require('fast-check/package-name');16console.log(packageName());17const packageName = require('fast-check-monorepo/package-name');18console.log(packageName());19const packageName = require('fast-check/package-name');20console.log(packageName());21const packageName = require('fast-check-monorepo/package-name');22console.log(packageName());23const packageName = require('fast-check/package-name');24console.log(packageName());25const packageName = require('fast-check-monorepo/package-name');26console.log(packageName());27const packageName = require('fast-check/package-name');28console.log(packageName());

Full Screen

Using AI Code Generation

copy

Full Screen

1const packageName = require('fast-check-monorepo/packageName');2console.log(packageName());3const packageName = require('fast-check-monorepo/packageName');4console.log(packageName());5import packageName from 'fast-check-monorepo/packageName';6console.log(packageName());7import packageName from 'fast-check-monorepo/packageName';8console.log(packageName());9import packageName from 'fast-check-monorepo/packageName';10console.log(packageName());11import packageName from 'fast-check-monorepo/packageName';12console.log(packageName());

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful