Best JavaScript code snippet using storybook-root
bundles.config.js
Source:bundles.config.js
1/**2 * Copyright 2018 The AMP HTML Authors. All Rights Reserved.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS-IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16'use strict';17/* global exports, process, require */18const colors = require('ansi-colors');19const log = require('fancy-log');20/**21 * @enum {string}22 */23const TYPES = exports.TYPES = {24 AD: '_base_ad',25 MEDIA: '_base_media',26 MISC: '_base_misc',27};28exports.extensionBundles = [29 {30 name: 'amp-3d-gltf',31 version: '0.1',32 latestVersion: '0.1',33 type: TYPES.MEDIA,34 },35 {36 name: 'amp-3q-player',37 version: '0.1',38 latestVersion: '0.1',39 type: TYPES.MEDIA,40 },41 {42 name: 'amp-access',43 version: '0.1',44 latestVersion: '0.1',45 options: {hasCss: true},46 type: TYPES.MISC,47 },48 {49 name: 'amp-access-laterpay',50 version: ['0.1', '0.2'],51 latestVersion: '0.2',52 options: {hasCss: true},53 type: TYPES.MISC,54 },55 {56 name: 'amp-access-scroll',57 version: '0.1',58 latestVersion: '0.1',59 options: {hasCss: true},60 type: TYPES.MISC,61 },62 {63 name: 'amp-access-poool',64 version: '0.1',65 latestVersion: '0.1',66 type: TYPES.MISC,67 },68 {69 name: 'amp-accordion',70 version: '0.1',71 latestVersion: '0.1',72 type: TYPES.MISC,73 },74 {75 name: 'amp-action-macro',76 version: '0.1',77 latestVersion: '0.1',78 type: TYPES.MISC,79 },80 {81 name: 'amp-ad',82 version: '0.1',83 latestVersion: '0.1',84 options: {hasCss: true},85 type: TYPES.AD,86 },87 {88 name: 'amp-ad-custom',89 version: '0.1',90 latestVersion: '0.1',91 type: TYPES.AD,92 },93 {94 name: 'amp-ad-network-adsense-impl',95 version: '0.1',96 latestVersion: '0.1',97 type: TYPES.AD,98 },99 {100 name: 'amp-ad-network-adzerk-impl',101 version: '0.1',102 latestVersion: '0.1',103 type: TYPES.AD,104 },105 {106 name: 'amp-ad-network-doubleclick-impl',107 version: '0.1',108 latestVersion: '0.1',109 type: TYPES.AD,110 },111 {112 name: 'amp-ad-network-fake-impl',113 version: '0.1',114 latestVersion: '0.1',115 type: TYPES.AD,116 },117 {118 name: 'amp-ad-network-triplelift-impl',119 version: '0.1',120 latestVersion: '0.1',121 type: TYPES.AD,122 },123 {124 name: 'amp-ad-network-cloudflare-impl',125 version: '0.1',126 latestVersion: '0.1',127 type: TYPES.AD,128 },129 {130 name: 'amp-ad-network-gmossp-impl',131 version: '0.1',132 latestVersion: '0.1',133 type: TYPES.AD,134 },135 {136 name: 'amp-ad-exit',137 version: '0.1',138 latestVersion: '0.1',139 type: TYPES.AD,140 },141 {142 name: 'amp-addthis',143 version: '0.1',144 latestVersion: '0.1',145 type: TYPES.MISC,146 },147 {148 name: 'amp-analytics',149 version: '0.1',150 latestVersion: '0.1',151 type: TYPES.MISC,152 },153 {154 name: 'amp-anim',155 version: '0.1',156 latestVersion: '0.1',157 type: TYPES.MEDIA,158 },159 {160 name: 'amp-animation',161 version: '0.1',162 latestVersion: '0.1',163 type: TYPES.MISC,164 },165 {166 name: 'amp-apester-media',167 version: '0.1',168 latestVersion: '0.1',169 options: {hasCss: true},170 type: TYPES.MEDIA,171 },172 {173 name: 'amp-app-banner',174 version: '0.1',175 latestVersion: '0.1',176 options: {hasCss: true},177 type: TYPES.MISC,178 },179 {180 name: 'amp-audio',181 version: '0.1',182 latestVersion: '0.1',183 type: TYPES.MEDIA,184 },185 {186 name: 'amp-auto-ads',187 version: '0.1',188 latestVersion: '0.1',189 type: TYPES.AD,190 },191 {192 name: 'amp-autocomplete',193 version: '0.1',194 latestVersion: '0.1',195 options: {hasCss: true},196 type: TYPES.MISC,197 },198 {199 name: 'amp-auto-lightbox',200 version: '0.1',201 latestVersion: '0.1',202 type: TYPES.MISC,203 },204 {205 name: 'amp-base-carousel',206 version: '0.1',207 latestVersion: '0.1',208 options: {hasCss: true},209 type: TYPES.MISC,210 },211 {212 name: 'amp-beopinion',213 version: '0.1',214 latestVersion: '0.1',215 type: TYPES.MISC,216 },217 {218 name: 'amp-bind',219 version: '0.1',220 latestVersion: '0.1',221 type: TYPES.MISC,222 },223 {224 name: 'amp-bodymovin-animation',225 version: '0.1',226 latestVersion: '0.1',227 type: TYPES.MEDIA,228 },229 {230 name: 'amp-brid-player',231 version: '0.1',232 latestVersion: '0.1',233 type: TYPES.MEDIA,234 },235 {236 name: 'amp-delight-player',237 version: '0.1',238 latestVersion: '0.1',239 options: {hasCss: true},240 type: TYPES.MEDIA,241 },242 {243 name: 'amp-brightcove',244 version: '0.1',245 latestVersion: '0.1',246 type: TYPES.MEDIA,247 },248 {249 name: 'amp-byside-content',250 version: '0.1',251 latestVersion: '0.1',252 options: {hasCss: true},253 type: TYPES.MISC,254 },255 {256 name: 'amp-kaltura-player',257 version: '0.1',258 latestVersion: '0.1',259 type: TYPES.MEDIA,260 },261 {262 name: 'amp-call-tracking',263 version: '0.1',264 latestVersion: '0.1',265 type: TYPES.MISC,266 },267 {268 name: 'amp-carousel',269 version: '0.1',270 latestVersion: '0.1',271 options: {hasCss: true},272 type: TYPES.MISC,273 },274 {275 name: 'amp-consent',276 version: '0.1',277 latestVersion: '0.1',278 options: {hasCss: true},279 type: TYPES.MISC,280 },281 {282 name: 'amp-crypto-polyfill',283 version: '0.1',284 latestVersion: '0.1',285 type: TYPES.MISC,286 },287 {288 name: 'amp-dailymotion',289 version: '0.1',290 latestVersion: '0.1',291 type: TYPES.MEDIA,292 },293 {294 name: 'amp-date-countdown',295 version: '0.1',296 latestVersion: '0.1',297 type: TYPES.MISC,298 },299 {300 name: 'amp-date-display',301 version: '0.1',302 latestVersion: '0.1',303 type: TYPES.MISC,304 },305 {306 name: 'amp-google-document-embed',307 version: '0.1',308 latestVersion: '0.1',309 type: TYPES.MISC,310 },311 {312 name: 'amp-dynamic-css-classes',313 version: '0.1',314 latestVersion: '0.1',315 type: TYPES.MISC,316 },317 {318 name: 'amp-embedly-card',319 version: '0.1',320 latestVersion: '0.1',321 type: TYPES.MISC,322 },323 {324 name: 'amp-experiment',325 version: '0.1',326 latestVersion: '0.1',327 type: TYPES.MISC,328 },329 {330 name: 'amp-facebook',331 version: '0.1',332 latestVersion: '0.1',333 type: TYPES.MISC,334 },335 {336 name: 'amp-facebook-comments',337 version: '0.1',338 latestVersion: '0.1',339 type: TYPES.MISC,340 },341 {342 name: 'amp-facebook-like',343 version: '0.1',344 latestVersion: '0.1',345 type: TYPES.MISC,346 },347 {348 name: 'amp-facebook-page',349 version: '0.1',350 latestVersion: '0.1',351 type: TYPES.MISC,352 },353 {354 name: 'amp-fit-text',355 version: '0.1',356 latestVersion: '0.1',357 options: {hasCss: true},358 type: TYPES.MISC,359 },360 {361 name: 'amp-font',362 version: '0.1',363 latestVersion: '0.1',364 type: TYPES.MISC,365 },366 {367 name: 'amp-form',368 version: '0.1',369 latestVersion: '0.1',370 options: {hasCss: true},371 type: TYPES.MISC,372 },373 {374 name: 'amp-fx-collection',375 version: '0.1',376 latestVersion: '0.1',377 type: TYPES.MISC,378 },379 {380 name: 'amp-fx-flying-carpet',381 version: '0.1',382 latestVersion: '0.1',383 options: {hasCss: true},384 type: TYPES.MISC,385 },386 {387 name: 'amp-geo',388 version: '0.1',389 latestVersion: '0.1',390 type: TYPES.MISC,391 },392 {393 name: 'amp-gfycat',394 version: '0.1',395 latestVersion: '0.1',396 type: TYPES.MEDIA,397 },398 {399 name: 'amp-gist',400 version: '0.1',401 latestVersion: '0.1',402 type: TYPES.MISC,403 },404 {405 name: 'amp-gwd-animation',406 version: '0.1',407 latestVersion: '0.1',408 options: {hasCss: true},409 type: TYPES.MISC,410 },411 {412 name: 'amp-hulu',413 version: '0.1',414 latestVersion: '0.1',415 type: TYPES.MEDIA,416 },417 {418 name: 'amp-iframe',419 version: '0.1',420 latestVersion: '0.1',421 type: TYPES.MISC,422 },423 {424 name: 'amp-ima-video',425 version: '0.1',426 latestVersion: '0.1',427 type: TYPES.MISC,428 },429 {430 name: 'amp-image-lightbox',431 version: '0.1',432 latestVersion: '0.1',433 options: {hasCss: true},434 type: TYPES.MISC,435 },436 {437 name: 'amp-image-slider',438 version: '0.1',439 latestVersion: '0.1',440 options: {hasCss: true},441 type: TYPES.MISC,442 },443 {444 name: 'amp-imgur',445 version: '0.1',446 latestVersion: '0.1',447 type: TYPES.MEDIA,448 },449 {450 name: 'amp-inputmask',451 version: '0.1',452 latestVersion: '0.1',453 type: TYPES.MISC,454 postPrepend: [455 'third_party/inputmask/bundle.js',456 ],457 },458 {459 name: 'amp-instagram',460 version: '0.1',461 latestVersion: '0.1',462 options: {hasCss: true},463 type: TYPES.MISC,464 },465 {466 name: 'amp-install-serviceworker',467 version: '0.1',468 latestVersion: '0.1',469 type: TYPES.MISC,470 },471 {472 name: 'amp-izlesene',473 version: '0.1',474 latestVersion: '0.1',475 type: TYPES.MEDIA,476 },477 {478 name: 'amp-jwplayer',479 version: '0.1',480 latestVersion: '0.1',481 type: TYPES.MEDIA,482 },483 {484 name: 'amp-lightbox',485 version: '0.1',486 latestVersion: '0.1',487 options: {hasCss: true},488 type: TYPES.MISC,489 },490 {491 name: 'amp-lightbox-gallery',492 version: '0.1',493 latestVersion: '0.1',494 options: {hasCss: true},495 type: TYPES.MISC,496 },497 {498 name: 'amp-list',499 version: '0.1',500 latestVersion: '0.1',501 options: {hasCss: true},502 type: TYPES.MISC,503 },504 {505 name: 'amp-live-list',506 version: '0.1',507 latestVersion: '0.1',508 options: {hasCss: true},509 type: TYPES.MISC,510 },511 {512 name: 'amp-mathml',513 version: '0.1',514 latestVersion: '0.1',515 options: {hasCss: true},516 type: TYPES.MISC,517 },518 {519 name: 'amp-mustache',520 version: ['0.1', '0.2'],521 latestVersion: '0.2',522 type: TYPES.MISC,523 },524 {525 name: 'amp-next-page',526 version: '0.1',527 latestVersion: '0.1',528 options: {hasCss: true},529 type: TYPES.MISC,530 },531 {532 name: 'amp-nexxtv-player',533 version: '0.1',534 latestVersion: '0.1',535 type: TYPES.MEDIA,536 },537 {538 name: 'amp-o2-player',539 version: '0.1',540 latestVersion: '0.1',541 type: TYPES.MEDIA,542 },543 {544 name: 'amp-ooyala-player',545 version: '0.1',546 latestVersion: '0.1',547 type: TYPES.MEDIA,548 },549 {550 name: 'amp-pinterest',551 version: '0.1',552 latestVersion: '0.1',553 options: {hasCss: true},554 type: TYPES.MISC,555 },556 {557 name: 'amp-playbuzz',558 version: '0.1',559 latestVersion: '0.1',560 options: {hasCss: true},561 type: TYPES.MEDIA,562 },563 {564 name: 'amp-reach-player',565 version: '0.1',566 latestVersion: '0.1',567 type: TYPES.MEDIA,568 },569 {570 name: 'amp-reddit',571 version: '0.1',572 latestVersion: '0.1',573 type: TYPES.MISC,574 },575 {576 name: 'amp-riddle-quiz',577 version: '0.1',578 latestVersion: '0.1',579 type: TYPES.MISC,580 },581 {582 name: 'amp-script',583 version: '0.1',584 latestVersion: '0.1',585 options: {hasCss: true},586 type: TYPES.MISC,587 },588 {589 name: 'amp-share-tracking',590 version: '0.1',591 latestVersion: '0.1',592 type: TYPES.MISC,593 },594 {595 name: 'amp-sidebar',596 version: '0.1',597 latestVersion: '0.1',598 options: {hasCss: true},599 type: TYPES.MISC,600 },601 {602 name: 'amp-skimlinks',603 version: '0.1',604 latestVersion: '0.1',605 type: TYPES.MISC,606 },607 {608 name: 'amp-smartlinks',609 version: '0.1',610 latestVersion: '0.1',611 type: TYPES.MISC,612 },613 {614 name: 'amp-soundcloud',615 version: '0.1',616 latestVersion: '0.1',617 type: TYPES.MEDIA,618 },619 {620 name: 'amp-springboard-player',621 version: '0.1',622 latestVersion: '0.1',623 type: TYPES.MEDIA,624 },625 {626 name: 'amp-sticky-ad',627 version: '1.0',628 latestVersion: '1.0',629 options: {hasCss: true},630 type: TYPES.AD,631 },632 {633 name: 'amp-story',634 version: '0.1',635 latestVersion: '1.0',636 options:637 {638 hasCss: true,639 cssBinaries: [640 'amp-story-bookend',641 'amp-story-consent',642 'amp-story-hint',643 'amp-story-unsupported-browser-layer',644 'amp-story-viewport-warning-layer',645 'amp-story-info-dialog',646 'amp-story-share',647 'amp-story-share-menu',648 'amp-story-system-layer',649 ],650 },651 type: TYPES.MISC,652 },653 {654 name: 'amp-story',655 version: '1.0',656 latestVersion: '1.0',657 options:658 {659 hasCss: true,660 cssBinaries: [661 'amp-story-bookend',662 'amp-story-tooltip',663 'amp-story-consent',664 'amp-story-hint',665 'amp-story-page-attachment-header',666 'amp-story-unsupported-browser-layer',667 'amp-story-viewport-warning-layer',668 'amp-story-info-dialog',669 'amp-story-share',670 'amp-story-share-menu',671 'amp-story-system-layer',672 ],673 },674 type: TYPES.MISC,675 },676 {677 name: 'amp-story-auto-ads',678 version: '0.1',679 latestVersion: '0.1',680 options: {hasCss: true},681 type: TYPES.MISC,682 },683 {684 name: 'amp-selector',685 version: '0.1',686 latestVersion: '0.1',687 options: {hasCss: true},688 type: TYPES.MISC,689 },690 {691 name: 'amp-web-push',692 version: '0.1',693 latestVersion: '0.1',694 options: {hasCss: true},695 type: TYPES.MISC,696 },697 {698 name: 'amp-wistia-player',699 version: '0.1',700 latestVersion: '0.1',701 type: TYPES.MEDIA,702 },703 {704 name: 'amp-position-observer',705 version: '0.1',706 latestVersion: '0.1',707 type: TYPES.MISC,708 },709 {710 name: 'amp-orientation-observer',711 version: '0.1',712 latestVersion: '0.1',713 type: TYPES.MISC,714 },715 {716 name: 'amp-date-picker',717 version: '0.1',718 latestVersion: '0.1',719 options: {hasCss: true},720 type: TYPES.MISC,721 postPrepend: [722 'third_party/react-dates/bundle.js',723 ],724 },725 {726 name: 'amp-image-viewer',727 version: '0.1',728 latestVersion: '0.1',729 options: {hasCss: true},730 type: TYPES.MISC,731 },732 {733 name: 'amp-subscriptions',734 version: '0.1',735 latestVersion: '0.1',736 options: {hasCss: true},737 type: TYPES.MISC,738 },739 {740 name: 'amp-subscriptions-google',741 version: '0.1',742 latestVersion: '0.1',743 options: {hasCss: true},744 type: TYPES.MISC,745 },746 {747 name: 'amp-pan-zoom',748 version: '0.1',749 latestVersion: '0.1',750 options: {hasCss: true},751 type: TYPES.MISC,752 },753 {754 name: 'amp-recaptcha-input',755 version: '0.1',756 latestVersion: '0.1',757 options: {hasCss: true},758 type: TYPES.MISC,759 },760 /**761 * @deprecated `amp-slides` is deprecated and will be deleted before 1.0.762 * Please see {@link AmpCarousel} with `type=slides` attribute instead.763 */764 {765 name: 'amp-slides',766 version: '0.1',767 latestVersion: '0.1',768 type: TYPES.MISC,769 },770 {771 name: 'amp-social-share',772 version: '0.1',773 latestVersion: '0.1',774 options: {hasCss: true},775 type: TYPES.MISC,776 },777 {778 name: 'amp-timeago',779 version: '0.1',780 latestVersion: '0.1',781 type: TYPES.MISC,782 },783 {784 name: 'amp-twitter',785 version: '0.1',786 latestVersion: '0.1',787 options: {hasCss: true},788 type: TYPES.MISC,789 },790 {791 name: 'amp-user-notification',792 version: '0.1',793 latestVersion: '0.1',794 options: {hasCss: true},795 type: TYPES.MISC,796 },797 {798 name: 'amp-vimeo',799 version: '0.1',800 latestVersion: '0.1',801 type: TYPES.MEDIA,802 },803 {804 name: 'amp-vine',805 version: '0.1',806 latestVersion: '0.1',807 type: TYPES.MISC,808 },809 {810 name: 'amp-viz-vega',811 version: '0.1',812 latestVersion: '0.1',813 options: {hasCss: true},814 type: TYPES.MISC,815 postPrepend: [816 'third_party/d3/d3.js',817 'third_party/d3-geo-projection/d3-geo-projection.js',818 'third_party/vega/vega.js',819 ],820 },821 {822 name: 'amp-google-vrview-image',823 version: '0.1',824 latestVersion: '0.1',825 type: TYPES.MISC,826 },827 {828 name: 'amp-viewer-assistance',829 version: '0.1',830 latestVersion: '0.1',831 type: TYPES.MISC,832 },833 {834 name: 'amp-viewer-integration',835 version: '0.1',836 latestVersion: '0.1',837 options:838 {839 // The viewer integration code needs to run asap, so that viewers840 // can influence document state asap. Otherwise the document may take841 // a long time to learn that it should start process other extensions842 // faster.843 loadPriority: 'high',844 },845 type: TYPES.MISC,846 },847 {848 name: 'amp-video',849 version: '0.1',850 latestVersion: '0.1',851 type: TYPES.MEDIA,852 },853 {854 name: 'amp-video-docking',855 version: '0.1',856 latestVersion: '0.1',857 options: {hasCss: true},858 type: TYPES.MEDIA,859 },860 {861 name: 'amp-video-iframe',862 version: '0.1',863 latestVersion: '0.1',864 type: TYPES.MEDIA,865 },866 {867 name: 'amp-viqeo-player',868 version: '0.1',869 latestVersion: '0.1',870 type: TYPES.MEDIA,871 },872 {873 name: 'amp-vk',874 version: '0.1',875 latestVersion: '0.1',876 type: TYPES.MISC,877 },878 {879 name: 'amp-yotpo',880 version: '0.1',881 latestVersion: '0.1',882 type: TYPES.MISC,883 },884 {885 name: 'amp-youtube',886 version: '0.1',887 latestVersion: '0.1',888 type: TYPES.MEDIA,889 },890 {891 name: 'amp-mowplayer',892 version: '0.1',893 latestVersion: '0.1',894 type: TYPES.MEDIA,895 },896 {897 name: 'amp-powr-player',898 version: '0.1',899 latestVersion: '0.1',900 type: TYPES.MEDIA,901 },902 {903 name: 'amp-mraid',904 version: '0.1',905 latestVersion: '0.1',906 type: TYPES.AD,907 },908];909exports.aliasBundles = [910 {911 name: 'amp-sticky-ad',912 version: '0.1',913 latestVersion: '1.0',914 options: {hasCss: true},915 type: 'ads',916 },917];918exports.altMainBundles = [919 {920 path: 'src/amp-shadow.js',921 name: 'shadow-v0',922 version: '0.1',923 latestVersion: '0.1',924 },925 {926 path: 'src/inabox/amp-inabox.js',927 name: 'amp4ads-v0',928 version: '0.1',929 latestVersion: '0.1',930 },931];932/**933 * @param {boolean} condition934 * @param {string} field935 * @param {string} message936 * @param {string} name937 * @param {string} found938 */939function verifyBundle_(condition, field, message, name, found) {940 if (!condition) {941 log(colors.red('ERROR:'),942 colors.cyan(field), message, colors.cyan(name),943 '\n' + found);944 process.exit(1);945 }946}947exports.verifyExtensionBundles = function() {948 exports.extensionBundles.forEach(bundle => {949 const bundleString = JSON.stringify(bundle, null, 2);950 verifyBundle_(951 'name' in bundle,952 'name', 'is missing from', '', bundleString);953 verifyBundle_(954 'version' in bundle,955 'version', 'is missing from', bundle.name, bundleString);956 verifyBundle_(957 'latestVersion' in bundle,958 'latestVersion', 'is missing from', bundle.name, bundleString);959 const duplicates = exports.extensionBundles.filter(960 duplicate => duplicate.name === bundle.name);961 verifyBundle_(962 duplicates.every(963 duplicate => duplicate.latestVersion === bundle.latestVersion),964 'latestVersion', 'is not the same for all versions of', bundle.name,965 JSON.stringify(duplicates, null, 2));966 verifyBundle_(967 'type' in bundle,968 'type', 'is missing from', bundle.name, bundleString);969 const validTypes = Object.keys(TYPES).map(x => TYPES[x]);970 verifyBundle_(971 validTypes.some(validType => validType === bundle.type),972 'type', `is not one of ${validTypes.join(',')} in`, bundle.name,973 bundleString);974 });975};976exports.verifyExtensionAliasBundles = function() {977 exports.aliasBundles.forEach(bundle => {978 const bundleString = JSON.stringify(bundle, null, 2);979 verifyBundle_(980 'name' in bundle,981 'name', 'is missing from', '', bundleString);982 verifyBundle_(983 'version' in bundle,984 'version', 'is missing from', bundle.name, bundleString);985 verifyBundle_(986 'latestVersion' in bundle,987 'latestVersion', 'is missing from', bundle.name, bundleString);988 });...
appVersions.js
Source:appVersions.js
1const { VERSION_CONSTANT } = require("../config/constant.js");2const config = require("config");3const mongoose = require("mongoose");4const express = require("express");5const router = express.Router();6const { adminAuth } = require("../middleware/auth");7const response = require("../service/response");8const _ = require("lodash");9const { Version, validateAppVersionPost } = require("../models/appVersion");10router.post("/", adminAuth, async (req, res) => {11 const { error } = validateAppVersionPost(req.body);12 if (error) return response.validationErrors(error.details);13 let version = await Version.findOne({ appType: req.body.appType });14 if (!version) {15 version = new Version(16 _.pick(req.body, [17 "major",18 "minor",19 "patch",20 "appType",21 "forceUpdateTitle",22 "forceUpdateMessage",23 "optionalUpdateTitle",24 "optionalUpdateMessage",25 "updateType",26 "showAppMaintainace",27 "isStickOnScreen",28 "appMaintainanceMesageTitle",29 "appMaintainanceMesageBody",30 "isShowImage",31 "imageUrl",32 ]),33 );34 } else {35 version.major = req.body.major;36 version.minor = req.body.minor;37 version.patch = req.body.patch;38 version.forceUpdateTitle = req.body.forceUpdateTitle;39 version.forceUpdateMessage = req.body.forceUpdateMessage;40 version.optionalUpdateTitle = req.body.optionalUpdateTitle;41 version.optionalUpdateMessage = req.body.optionalUpdateMessage;42 version.updateType = req.body.updateType;43 version.showAppMaintainace = req.body.showAppMaintainace;44 version.isStickOnScreen = req.body.isStickOnScreen;45 version.appMaintainanceMesageTitle = req.body.appMaintainanceMesageTitle;46 version.appMaintainanceMesageBody = req.body.appMaintainanceMesageBody;47 version.isShowImage = req.body.isShowImage;48 version.imageUrl = req.body.imageUrl;49 }50 await version.save();51 return res.send({52 statusCode: 200,53 message: "Success",54 data: VERSION_CONSTANT.SUBMIT_SUCCESS,55 });56});57router.get("/check", async (req, res) => {58 let respObj = {};59 respObj.optionalUpdate = false;60 respObj.forceUpdate = false;61 respObj.forceUpdateTitle = "";62 respObj.forceUpdateMessage = "";63 respObj.optionalUpdateTitle = "";64 respObj.optionalUpdateMessage = "";65 respObj.showAppMaintainace = false;66 respObj.isStickOnScreen = false;67 respObj.appMaintainanceMesageTitle = "";68 respObj.appMaintainanceMesageBody = "";69 respObj.isShowImage = false;70 respObj.imageUrl = "";71 if (!req.query.v) {72 return res.send({73 statusCode: 200,74 message: "Success",75 data: {76 optionalUpdate: false,77 forceUpdate: false,78 message: VERSION_CONSTANT.VERSION_MANDATORY,79 },80 });81 } else if (!req.query.appType) {82 return res.send({83 statusCode: 200,84 message: "Success",85 data: {86 optionalUpdate: false,87 forceUpdate: false,88 message: VERSION_CONSTANT.APPTYPE_MANDATORY,89 },90 });91 }92 let versionArray = req.query.v.split(".");93 let major = 0;94 let minor = 0;95 let patch = 0;96 if (versionArray[0]) major = parseInt(versionArray[0]);97 if (versionArray[1]) minor = parseInt(versionArray[1]);98 if (versionArray[2]) patch = parseInt(versionArray[2]);99 if (isNaN(major))100 return res.send({ statusCode: 200, message: "Success", data: respObj });101 else if (isNaN(minor))102 return res.send({ statusCode: 200, message: "Success", data: respObj });103 else if (isNaN(patch)) {104 return res.send({ statusCode: 200, message: "Success", data: respObj });105 }106 let flag = 0; // Flag 1 -> mandatory . Flag 2 -> Recommended.107 let latestVersionList = await Version.aggregate([108 { $match: { appType: req.query.appType } },109 { $sort: { insertDate: -1 } },110 { $limit: 1 },111 ]);112 if (!latestVersionList.length) {113 return res.send({ statusCode: 200, message: "Success", data: respObj });114 }115 let latestVersion = latestVersionList[0];116 if (major < latestVersion.major) {117 flag = 1;118 } else if (minor < latestVersion.minor) {119 if (120 latestVersion.updateType == "minor" ||121 latestVersion.updateType == "patch"122 ) {123 flag = 1;124 } else {125 flag = 2;126 }127 } else if (patch < latestVersion.patch) {128 if (latestVersion.updateType == "patch") {129 flag = 1;130 } else {131 flag = 2;132 }133 }134 if (flag == 1) {135 respObj.optionalUpdate = false;136 respObj.forceUpdate = true;137 respObj.forceUpdateTitle = latestVersion.forceUpdateTitle;138 respObj.forceUpdateMessage = latestVersion.forceUpdateMessage;139 respObj.optionalUpdateTitle = latestVersion.optionalUpdateTitle;140 respObj.optionalUpdateMessage = latestVersion.optionalUpdateMessage;141 respObj.showAppMaintainace = latestVersion.showAppMaintainace;142 respObj.isStickOnScreen = latestVersion.isStickOnScreen;143 respObj.appMaintainanceMesageTitle =144 latestVersion.appMaintainanceMesageTitle;145 respObj.appMaintainanceMesageBody = latestVersion.appMaintainanceMesageBody;146 respObj.isShowImage = latestVersion.isShowImage;147 respObj.imageUrl = latestVersion.imageUrl;148 }149 if (flag == 2) {150 respObj.optionalUpdate = true;151 respObj.forceUpdate = false;152 respObj.forceUpdateTitle = latestVersion.forceUpdateTitle;153 respObj.forceUpdateMessage = latestVersion.forceUpdateMessage;154 respObj.optionalUpdateTitle = latestVersion.optionalUpdateTitle;155 respObj.optionalUpdateMessage = latestVersion.optionalUpdateMessage;156 respObj.showAppMaintainace = latestVersion.showAppMaintainace;157 respObj.isStickOnScreen = latestVersion.isStickOnScreen;158 respObj.appMaintainanceMesageTitle =159 latestVersion.appMaintainanceMesageTitle;160 respObj.appMaintainanceMesageBody = latestVersion.appMaintainanceMesageBody;161 respObj.isShowImage = latestVersion.isShowImage;162 respObj.imageUrl = latestVersion.imageUrl;163 }164 respObj.showAppMaintainace = latestVersion.showAppMaintainace;165 respObj.isStickOnScreen = latestVersion.isStickOnScreen;166 respObj.appMaintainanceMesageTitle = latestVersion.appMaintainanceMesageTitle;167 respObj.appMaintainanceMesageBody = latestVersion.appMaintainanceMesageBody;168 respObj.isShowImage = latestVersion.isShowImage;169 respObj.imageUrl = latestVersion.imageUrl;170 return res.send({ statusCode: 200, message: "Success", data: respObj });171});172router.get("/list", adminAuth, async (req, res) => {173 let versionList = await Version.find({});174 return res.send({175 statusCode: 200,176 message: "Success",177 data: { versionList },178 });179});...
loader.user.js
Source:loader.user.js
1// ==UserScript==2// @name AposLoader3// @namespace AposLoader4// @description Grabs latest versions of the bot scripts automatically.5// @include http://agar.io/6// @version 1.37// @grant none8// @author http://www.twitch.tv/apostolique9// ==/UserScript==10var aposLoaderVersion = 1.3;11var sha = "efde0488cc2cc176db48dd23b28a20b90314352b";12function getLatestCommit() {13 window.jQuery.ajax({14 url: "https://api.github.com/repos/apostolique/Agar.io-bot/git/refs/heads/master",15 cache: false,16 dataType: "jsonp"17 }).done(function(data) {18 console.dir(data["data"])19 console.log("hmm: " + data["data"]["object"]["sha"]);20 sha = data["data"]["object"]["sha"];;21 window.jQuery.get('https://raw.githubusercontent.com/Apostolique/Agar.io-bot/master/launcher.user.js?' + Math.floor((Math.random() * 1000000) + 1), function(data) {22 var latestVersion = data.replace(/(\r\n|\n|\r)/gm, "");23 latestVersion = latestVersion.substring(latestVersion.indexOf("// @version") + 11, latestVersion.indexOf("// @grant"));24 latestVersion = parseFloat(latestVersion + 0.0000);25 var script1 = "https://cdn.rawgit.com/Apostolique/Agar.io-bot/" + sha + "/launcher.user.js";26 console.log("Script: " + script1);27 window.jQuery("body").append('<script type="text/javascript" src="' + script1 + '"></script>');28 });29 window.jQuery.get('https://raw.githubusercontent.com/Apostolique/Agar.io-bot/master/bot.user.js?' + Math.floor((Math.random() * 1000000) + 1), function(data) {30 var latestVersion = data.replace(/(\r\n|\n|\r)/gm, "");31 latestVersion = latestVersion.substring(latestVersion.indexOf("// @version") + 11, latestVersion.indexOf("// @grant"));32 latestVersion = parseFloat(latestVersion + 0.0000);33 var script2 = "https://cdn.rawgit.com/Apostolique/Agar.io-bot/" + sha + "/bot.user.js";34 console.log("Script: " + script2);35 window.jQuery("body").append('<script type="text/javascript" src="' + script2 + '"></script>');36 });37 function update(prefix, name, url) {38 window.jQuery(document.body).prepend("<div id='" + prefix + "Dialog' style='position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 100; display: none;'>");39 window.jQuery('#' + prefix + 'Dialog').append("<div id='" + prefix + "Message' style='width: 350px; background-color: #FFFFFF; margin: 100px auto; border-radius: 15px; padding: 5px 15px 5px 15px;'>");40 window.jQuery('#' + prefix + 'Message').append("<h2>UPDATE TIME!!!</h2>");41 window.jQuery('#' + prefix + 'Message').append("<p>Grab the update for: <a id='" + prefix + "Link' href='" + url + "' target=\"_blank\">" + name + "</a></p>");42 window.jQuery('#' + prefix + 'Link').on('click', function() {43 window.jQuery("#" + prefix + "Dialog").hide();44 window.jQuery("#" + prefix + "Dialog").remove();45 });46 window.jQuery("#" + prefix + "Dialog").show();47 }48 window.jQuery.get('https://raw.githubusercontent.com/Apostolique/Agar.io-bot/master/loader.user.js?' + Math.floor((Math.random() * 1000000) + 1), function(data) {49 var latestVersion = data.replace(/(\r\n|\n|\r)/gm, "");50 latestVersion = latestVersion.substring(latestVersion.indexOf("// @version") + 11, latestVersion.indexOf("// @grant"));51 latestVersion = parseFloat(latestVersion + 0.0000);52 var myVersion = parseFloat(aposLoaderVersion + 0.0000);53 if (latestVersion > myVersion) {54 update("aposLoader", "loader.user.js", "https://github.com/Apostolique/Agar.io-bot/blob/master/loader.user.js/");55 }56 console.log('Current loader.user.js Version: ' + myVersion + " on Github: " + latestVersion);57 });58 }).fail(function() {});59}...
Using AI Code Generation
1import storybookRoot from 'storybook-root';2import { latestVersion } from 'storybook-root';3import { latestVersion } from 'storybook-root';4import storybookRoot from 'storybook-root';5import { latestVersion } from 'storybook-root';6import { latestVersion } from 'storybook-root';7import storybookRoot from 'storybook-root';8import { latestVersion } from 'storybook-root';9import { latestVersion } from 'storybook-root';10import storybookRoot from 'storybook-root';11import { latestVersion } from 'storybook-root';12import { latestVersion } from 'storybook-root';13import storybookRoot from 'storybook-root';14import { latestVersion } from 'storybook-root';15import { latestVersion } from 'storybook-root';16import storybookRoot from 'storybook-root';17import { latestVersion } from 'storybook-root';18import { latestVersion } from 'storybook-root';19import storybookRoot from 'storybook-root';20import { latestVersion } from 'storybook-root';21import { latestVersion } from 'storybook-root';22import storybookRoot from 'storybook-root';23import { latestVersion } from 'storybook-root';24import { latestVersion } from 'storybook-root';25import storybookRoot from 'storybook-root';26import { latestVersion } from 'storybook-root';
Using AI Code Generation
1import { latestVersion } from '@storybook/root';2const version = latestVersion();3console.log(version);4{5 "dependencies": {6 }7}8import { latestVersion } from '@storybook/addon-knobs';9const version = latestVersion();10console.log(version);11{12 "dependencies": {13 }14}
Using AI Code Generation
1const storybookRoot = require('storybook-root');2const latestVersion = storybookRoot.latestVersion;3const path = require('path');4const packageJson = path.join(__dirname, 'package.json');5latestVersion(packageJson).then((version) => {6 console.log(version);7});
Using AI Code Generation
1const { latestVersion } = require('storybook-root-cause');2const { version } = require('./package.json');3const latest = await latestVersion();4console.log(latest === version);5const { latestVersion } = require('storybook-root-cause');6const { version } = require('./package.json');7const latest = await latestVersion();8console.log(latest === version);
Using AI Code Generation
1import { latestVersion } from 'storybook-root';2latestVersion('react');3import { latestVersion } from 'storybook-root';4const version = await latestVersion('react');5import { latestVersion } from 'storybook-root';6latestVersion('react').then(version => {7 console.log(version);8});9import { latestVersion } from 'storybook-root';10async function getVersion() {11 const version = await latestVersion('react');12 console.log(version);13}14getVersion();15import { latestVersion } from 'storybook-root';16async function getVersion() {17 try {18 const version = await latestVersion('react');19 console.log(version);20 } catch (error) {21 console.log(error);22 }23}24getVersion();25import { latestVersion } from 'storybook-root';26async function getVersion() {27 try {28 const version = await latestVersion('react');29 console.log(version);30 } catch (error) {31 console.log(error);32 }33}34getVersion();35import { latestVersion } from 'storybook-root';36async function getVersion() {37 try {38 const version = await latestVersion('react');39 console.log(version);40 } catch (error) {41 console.log(error);42 }43}44getVersion();45import { latestVersion } from 'storybook-root';46async function getVersion() {47 try {48 const version = await latestVersion('react');49 console.log(version);50 } catch (error) {51 console.log(error);52 }53}
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!