def build_js_files(dev_mode_setting, deparallelize_terser=False, source_maps=False): """Build the javascript files. Args: dev_mode_setting: bool. Represents whether to run the related commands in dev mode. deparallelize_terser: bool. Represents whether to use webpack compilation config that disables parallelism on terser plugin. source_maps: bool. Represents whether to use source maps while building webpack. """ if not dev_mode_setting: python_utils.PRINT(' Generating files for production mode...') build_args = ['--prod_env'] if deparallelize_terser: build_args.append('--deparallelize_terser') if source_maps: build_args.append('--source_maps') build.main(args=build_args) else: build.main(args=[]) run_webpack_compilation(source_maps=source_maps)
def main(args=None): """Runs lighthouse checks and deletes reports.""" parsed_args = _PARSER.parse_args(args=args) if parsed_args.mode == LIGHTHOUSE_MODE_ACCESSIBILITY: lighthouse_mode = LIGHTHOUSE_MODE_ACCESSIBILITY server_mode = SERVER_MODE_DEV elif parsed_args.mode == LIGHTHOUSE_MODE_PERFORMANCE: lighthouse_mode = LIGHTHOUSE_MODE_PERFORMANCE server_mode = SERVER_MODE_PROD else: raise Exception('Invalid parameter passed in: \'%s\', please choose' 'from \'accessibility\' or \'performance\'' % parsed_args.mode) enable_webpages() atexit.register(cleanup) if lighthouse_mode == LIGHTHOUSE_MODE_PERFORMANCE: python_utils.PRINT('Building files in production mode.') # We are using --source_maps here, so that we have at least one CI check # that builds using source maps in prod env. This is to ensure that # there are no issues while deploying oppia. build.main(args=['--prod_env', '--source_maps']) elif lighthouse_mode == LIGHTHOUSE_MODE_ACCESSIBILITY: build.main(args=[]) run_webpack_compilation() else: raise Exception('Invalid lighthouse mode: \'%s\', please choose' 'from \'accessibility\' or \'performance\'' % lighthouse_mode) common.start_redis_server() # TODO(#11549): Move this to top of the file. import contextlib2 managed_dev_appserver = common.managed_dev_appserver( APP_YAML_FILENAMES[server_mode], port=GOOGLE_APP_ENGINE_PORT, clear_datastore=True, log_level='critical', skip_sdk_update_check=True) with contextlib2.ExitStack() as stack: stack.enter_context(common.managed_elasticsearch_dev_server()) if constants.EMULATOR_MODE: stack.enter_context(common.managed_firebase_auth_emulator()) stack.enter_context(managed_dev_appserver) # Wait for the servers to come up. common.wait_for_port_to_be_in_use(feconf.ES_LOCALHOST_PORT) common.wait_for_port_to_be_in_use(GOOGLE_APP_ENGINE_PORT) run_lighthouse_puppeteer_script() run_lighthouse_checks(lighthouse_mode)
def main(): """Runs lighthouse checks and deletes reports.""" enable_webpages() atexit.register(cleanup) python_utils.PRINT('Building files in production mode.') build.main(args=['--prod_env']) build.modify_constants(prod_env=True) start_google_app_engine_server() common.wait_for_port_to_be_open(GOOGLE_APP_ENGINE_PORT) run_lighthouse_checks()
def main(): """Runs lighthouse checks and deletes reports.""" enable_webpages() atexit.register(cleanup) python_utils.PRINT('Building files in production mode.') # We are using --source_maps here, so that we have at least one CI check # that builds using source maps in prod env. This is to ensure that # there are no issues while deploying oppia. build.main(args=['--prod_env', '--source_maps']) common.start_redis_server() start_google_app_engine_server() common.wait_for_port_to_be_open(GOOGLE_APP_ENGINE_PORT) run_lighthouse_checks()
def main(args=None): """Runs lighthouse checks and deletes reports.""" parsed_args = _PARSER.parse_args(args=args) if parsed_args.mode == LIGHTHOUSE_MODE_ACCESSIBILITY: lighthouse_mode = LIGHTHOUSE_MODE_ACCESSIBILITY server_mode = SERVER_MODE_DEV elif parsed_args.mode == LIGHTHOUSE_MODE_PERFORMANCE: lighthouse_mode = LIGHTHOUSE_MODE_PERFORMANCE server_mode = SERVER_MODE_PROD else: raise Exception( 'Invalid parameter passed in: \'%s\', please choose' 'from \'accessibility\' or \'performance\'' % parsed_args.mode) if lighthouse_mode == LIGHTHOUSE_MODE_PERFORMANCE: python_utils.PRINT('Building files in production mode.') # We are using --source_maps here, so that we have at least one CI check # that builds using source maps in prod env. This is to ensure that # there are no issues while deploying oppia. build.main(args=['--prod_env', '--source_maps']) elif lighthouse_mode == LIGHTHOUSE_MODE_ACCESSIBILITY: build.main(args=[]) run_webpack_compilation() with python_utils.ExitStack() as stack: stack.enter_context(common.inplace_replace_file_context( common.CONSTANTS_FILE_PATH, '"ENABLE_ACCOUNT_DELETION": .*', '"ENABLE_ACCOUNT_DELETION": true,')) stack.enter_context(servers.managed_redis_server()) stack.enter_context(servers.managed_elasticsearch_dev_server()) if constants.EMULATOR_MODE: stack.enter_context(servers.managed_firebase_auth_emulator()) stack.enter_context(servers.managed_dev_appserver( APP_YAML_FILENAMES[server_mode], port=GOOGLE_APP_ENGINE_PORT, clear_datastore=True, log_level='critical', skip_sdk_update_check=True)) run_lighthouse_puppeteer_script() run_lighthouse_checks(lighthouse_mode)
def build_js_files(dev_mode_setting): """Build the javascript files. Args: dev_mode_setting: bool. Represents whether to run the related commands in dev mode. """ update_dev_mode_in_constants_js(CONSTANT_FILE_PATH, dev_mode_setting) if not dev_mode_setting: python_utils.PRINT(' Generating files for production mode...') build.main(args=['--prod_env']) else: # The 'hashes.json' file is used by the `url-interpolation` service. if not os.path.isfile(HASHES_FILE_PATH): with python_utils.open_file(HASHES_FILE_PATH, 'w') as hash_file: hash_file.write('{}') build.main(args=[]) run_webpack_compilation()
def build_js_files(dev_mode, source_maps=False): """Build the javascript files. Args: dev_mode: bool. Represents whether to run the related commands in dev mode. source_maps: bool. Represents whether to use source maps while building webpack. """ if not dev_mode: print('Generating files for production mode...') build_args = ['--prod_env'] if source_maps: build_args.append('--source_maps') build.main(args=build_args) else: build.main(args=[]) run_webpack_compilation(source_maps=source_maps)
def main(args=None): """Runs lighthouse checks and deletes reports.""" parsed_args = _PARSER.parse_args(args=args) if parsed_args.mode == LIGHTHOUSE_MODE_ACCESSIBILITY: lighthouse_mode = LIGHTHOUSE_MODE_ACCESSIBILITY server_mode = SERVER_MODE_DEV elif parsed_args.mode == LIGHTHOUSE_MODE_PERFORMANCE: lighthouse_mode = LIGHTHOUSE_MODE_PERFORMANCE server_mode = SERVER_MODE_PROD else: raise Exception('Invalid parameter passed in: \'%s\', please choose' 'from \'accessibility\' or \'performance\'' % parsed_args.mode) if lighthouse_mode == LIGHTHOUSE_MODE_PERFORMANCE: print('Building files in production mode.') build.main(args=['--prod_env']) elif lighthouse_mode == LIGHTHOUSE_MODE_ACCESSIBILITY: build.main(args=[]) run_webpack_compilation() with contextlib.ExitStack() as stack: stack.enter_context(servers.managed_redis_server()) stack.enter_context(servers.managed_elasticsearch_dev_server()) if constants.EMULATOR_MODE: stack.enter_context(servers.managed_firebase_auth_emulator()) stack.enter_context(servers.managed_cloud_datastore_emulator()) stack.enter_context( servers.managed_dev_appserver(APP_YAML_FILENAMES[server_mode], port=GOOGLE_APP_ENGINE_PORT, log_level='critical', skip_sdk_update_check=True)) run_lighthouse_puppeteer_script() run_lighthouse_checks(lighthouse_mode, parsed_args.shard)
def main(args=None): """Runs lighthouse checks and deletes reports.""" parsed_args = _PARSER.parse_args(args=args) if parsed_args.mode == LIGHTHOUSE_MODE_ACCESSIBILITY: lighthouse_mode = LIGHTHOUSE_MODE_ACCESSIBILITY server_mode = SERVER_MODE_DEV elif parsed_args.mode == LIGHTHOUSE_MODE_PERFORMANCE: lighthouse_mode = LIGHTHOUSE_MODE_PERFORMANCE server_mode = SERVER_MODE_PROD else: raise Exception( 'Invalid parameter passed in: \'%s\', please choose' 'from \'accessibility\' or \'performance\'' % parsed_args.mode) enable_webpages() atexit.register(cleanup) if lighthouse_mode == LIGHTHOUSE_MODE_PERFORMANCE: python_utils.PRINT('Building files in production mode.') # We are using --source_maps here, so that we have at least one CI check # that builds using source maps in prod env. This is to ensure that # there are no issues while deploying oppia. build.main(args=['--prod_env', '--source_maps']) elif lighthouse_mode == LIGHTHOUSE_MODE_ACCESSIBILITY: build.main(args=[]) run_webpack_compilation() else: raise Exception( 'Invalid lighthouse mode: \'%s\', please choose' 'from \'accessibility\' or \'performance\'' % lighthouse_mode) common.start_redis_server() start_google_app_engine_server(server_mode) common.wait_for_port_to_be_open(GOOGLE_APP_ENGINE_PORT) run_lighthouse_puppeteer_script() run_lighthouse_checks(lighthouse_mode)
def build_js_files(dev_mode_setting): """Build the javascript files. Args: dev_mode_setting: bool. Represents whether to run the related commands in dev mode. """ update_dev_mode_in_constants_js(CONSTANT_FILE_PATH, dev_mode_setting) if not dev_mode_setting: python_utils.PRINT(' Generating files for production mode...') else: # The 'hashes.json' file is used by the `url-interpolation` service. if not os.path.isfile(HASHES_FILE_PATH): with python_utils.open_file(HASHES_FILE_PATH, 'w') as hash_file: hash_file.write('{}') try: common.run_cmd([ common.NODE_BIN_PATH, WEBPACK_BIN_PATH, '--config', 'webpack.dev.config.ts' ]) except subprocess.CalledProcessError as error: python_utils.PRINT(error.output) sys.exit(error.returncode) build.main(args=(['--prod_env'] if not dev_mode_setting else []))
def build_js_files(dev_mode_setting, deparallelize_terser=False): """Build the javascript files. Args: dev_mode_setting: bool. Represents whether to run the related commands in dev mode. deparallelize_terser: bool. Represents whether to use webpack compilation config that disables parallelism on terser plugin. """ if not dev_mode_setting: python_utils.PRINT(' Generating files for production mode...') if deparallelize_terser: build.main(args=['--prod_env', '--deparallelize_terser']) else: build.main(args=['--prod_env']) else: # The 'hashes.json' file is used by the `url-interpolation` service. if not os.path.isfile(HASHES_FILE_PATH): with python_utils.open_file(HASHES_FILE_PATH, 'w') as hash_file: hash_file.write('{}') build.main(args=[]) run_webpack_compilation()