JavaScript module resource.

@class
@extends {FileResource}

@constructor
@param {Package} pkg Package this resource is part of
@param {Object|string[]|string} config Resource configuration or one or more resource file paths
430053
function ModuleResource( pkg, config ) {
	// Parent constructor
	ModuleResource.super.call( this, pkg, config );

	// Properties
	this.imports = config.imports || null;
	this.exports = config.exports || null;
	this.propertyNamePattern = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;
}
740005
function package(cb) {
    const pkgjson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
    delete pkgjson.scripts;
    delete pkgjson.devDependencies;
    const filepath = './dist/package.json';
    fs.writeFileSync(filepath, JSON.stringify(pkgjson, null, 2), 'utf-8');
    console.log('package.json Copied to Dist Directory');
    cb();
}
71837
def add_package(pkg_type, pkg_name, working=None):
    
    kvp = {pkg_type: pkg_name}
    working = os.getcwd() if not working else os.path.abspath(working)
    if '-dist/scripts' in working:
        config = working + "/config.JSON"
    elif '-dist' in working:
        config = working + "/scripts/config.JSON"
    else:
        config = working + "/*-dist/scripts/config.JSON"
        entropy = glob.glob(config)
        if entropy:
            config = entropy[0]  # we'll just assume it's the first one...
    print("config", config, 'working', working)
    config = load_config(config)
    config.update(kvp)
    export_to_json(config)
1200620
function createConfig(pkg, moduleFormat, productive) {
  return {
    input: `src/modules/${pkg}/main/index.ts`, 

    output: {
      file: productive
        ? `dist/js-surface.${pkg}.${moduleFormat}.production.js`
        : `dist/js-surface.${pkg}.${moduleFormat}.development.js`,

      format: moduleFormat,
      
      name: {
        core: 'jsSurface',
        all: 'jsSurface',
        html: 'jsSurface.Html',
        svg: 'jsSurface.Svg'
      }[pkg] || `jsSurface.${pkg}`,
     
      sourcemap: productive ? false : 'inline',

      globals: {
        'js-surface': 'jsSurface',
        'react': 'React',
        'react-dom': 'ReactDOM',
        'dyo': 'Dyo',
        'js-spec': 'jsSpec'
      }
    },

    external: ['js-surface', 'react', 'react-dom', 'dyo'].concat(productive ? 'js-spec' : []), 

    plugins: [
      resolve({
        jsnext: true,
        main: true,
        browser: true,
      }),
      commonjs(),
      // TODO: Configure "tslint.json" properly and fix all errors
      //tslint({
      //  throwOnError: true
      //}),
      replace({
        exclude: 'node_modules/**',
        delimiters: ['', ''],

        values:
          pkg === 'all' ? {
            'process.env.NODE_ENV': productive ? "'production'" : "'development'",
          } : {
            'process.env.NODE_ENV': productive ? "'production'" : "'development'",
            "'../core/main/index'": "'js-surface'",
            "'../../core/main/index'": "'js-surface'",
            "'../../../core/main/index'": "'js-surface'",
            "'../../../../core/main/index'": "'js-surface'",
            "'../../../../../core/main/index'": "'js-surface'",
          }
      }),
      typescript({
        exclude: 'node_modules/**',
      }),
      productive && (moduleFormat === 'esm' ? terser() : uglify()),
      productive && gzip()
    ],
  }
}
269056
function loadConfigFile(configInfo) {
    const { filePath } = configInfo;
    let config;

    switch (path.extname(filePath)) {
        case ".js":
            config = loadJSConfigFile(filePath);
            if (configInfo.configName) {
                config = config.configs[configInfo.configName];
                if (!config) {
                    throw configMissingError(configInfo.configFullName);
                }
            }
            break;

        case ".json":
            if (path.basename(filePath) === "package.json") {
                config = loadPackageJSONConfigFile(filePath);
                if (config === null) {
                    return null;
                }
            } else {
                config = loadJSONConfigFile(filePath);
            }
            break;

        case ".yaml":
        case ".yml":
            config = loadYAMLConfigFile(filePath);
            break;

        default:
            config = loadLegacyConfigFile(filePath);
    }

    return ConfigOps.merge(ConfigOps.createEmptyConfig(), config);
}
222338
async function write(packageName, pkg) {
  const packagePath = path.join(cwd, packageName, 'package.json');

  await fs.writeFile(packagePath, `${JSON.stringify(pkg, null, 2)}\n`);
}
1168814
function App(opts) {
    opts = opts || {};

    var path = opts.path || PATH.dirname(require.main.filename);

    // provides ym define&require interface
    var ym = YM.create();

    /**
     * @api
     * @param {string} moduleName
     * @param {string[]} [dependencies]
     * @param {function(function(*, ?Error=), ...*)} declarationFunction
     */
    this.define = ym.define;

    /**
     * @api
     * @param {string[]} dependencies
     * @param {function(Array<*>)} successCallbackFunction
     * @param {function(Error)} [errorCallbackFunction]
     */
    this.require = ym.require;

    /**
     * Loads node package with module provisions
     * @api
     * @param {(string|string[]|Object|Function)} pkg - package name, or list of,
     *   or package object, or package function
     * @returns {PYM} this
     */
    this.usePackage = function usePackage(pkg, options) {
        options = options || {};

        var resolvedPackage = _resolvePackageSync(path, pkg);
        resolvedPackage.exports(this, options);

        return this;
    };

    // load required modules if passed
    if (opts.uses) {
        if (Array.isArray(opts.uses)) {
            opts.uses.forEach(function (plugin) {
                this.usePackage(plugin);
            }, this);
        } else if (typeof opts.uses === 'object') {
            Object.keys(opts.uses).forEach(function (key) {
                this.usePackage(key, opts.uses[key]);
            }, this);
        } else {
            throw new Error('Unsupported value in uses property');
        }
    }
}
897348
function npmLoad(context, pkg){
	var task = new FetchTask(context, pkg);

	return task.load().then(function(){
		if(task.failed) {
			// Recurse. Calling task.next gives us a new pkg object
			// with the fileUrl being the parent node_modules folder.
			return npmLoad(context, task.next());
		}
		return task.getPackage();
	});
}
437237
function (data) {

            if (!isLog()) {
                return undefined;
            }

            try {
                _fs.appendFileSync("pkgscript.log", (_utils.now() + "  " + data + "\n"), "utf8");

            } catch (e) {
                console.error(_utils.now + " [package-script] Package Script, ERROR:", e);
            }
        }
20200
function setup(config, options) {
  const rule = config.module.rule("svg"); // Find the svg rule

  /*
   * Let's use the file loader option defaults for the svg loader again. Otherwise
   * we'll have to set our own and it's no longer consistent with the changing
   * vue-cli.
   */
  const fileLoaderOptions = rule.use("file-loader").get("options"); // Get the file loader options
  options.external = _.merge(fileLoaderOptions, options.external); // Make sure we save the file loader options

  // Use file loader options for sprite name
  options.sprite = _.merge(
    { spriteFilename: fileLoaderOptions.name },
    options.sprite
  );

  rule.uses.clear(); // Clear out existing uses of the svg rule
  const query = parseResourceQuery(options); // Get the resource queries

  rule
    .oneOf("inline")
    .resourceQuery(query.inline)
    .use("vue-svg-loader")
    .loader("vue-svg-loader")
    .options(options.inline);

  rule
    .oneOf("sprite")
    .resourceQuery(query.sprite)
    .use("svg-sprite-loader")
    .loader("svg-sprite-loader")
    .options(options.sprite);

  rule
    .oneOf("data")
    .resourceQuery(query.data)
    .use("url-loader")
    .loader("url-loader")
    .options(options.data);

  rule
    .oneOf("external")
    .use("file-loader")
    .loader("file-loader")
    .options(options.external);
}
380638
def link(self, path, pkg):
        
        # Check if a custom linker exists to handle linking this package
        #for ep in pkg_resources.iter_entry_points(group="enaml_native_linker"):
        #    if ep.name.replace("-", '_') == pkg.replace("-", '_'):
        #        linker = ep.load()
        #        print("Custom linker {} found for '{}'. Linking...".format(
        #            linker, pkg))
        #        if linker(self.ctx, path):
        #            return

        #: Use the default builtin linker script
        if exists(join(path, pkg, 'build.gradle')):
            print(Colors.BLUE+"[INFO] Linking {}/build.gradle".format(
                  pkg)+Colors.RESET)
            self.link_android(path, pkg)
        if exists(join(path, pkg, 'Podfile')):
            print(Colors.BLUE+"[INFO] Linking {}/Podfile".format(
                  pkg)+Colors.RESET)
            self.link_ios(path, pkg)
392990
function (config, component) {
    var componentConfigFile;

    ['bower.json', '.bower.json', 'component.json', 'package.json'].
    forEach(function (configFile) {

        configFile = path.join(config.get('bower-directory'), component, configFile);

        console.log(configFile);

        if (!_.isObject(componentConfigFile) && fs.existsSync(configFile)) {
            componentConfigFile = JSON.parse(fs.readFileSync(configFile));
        }
    });



    return componentConfigFile;
}
83029
function (module) {
        "use strict";
    
        var getResource = function (hostType, resource) {
    
            var host;
            var modulePath, filePath;
    
            if (resource.substr(0, 1) === '/') {
                resource = resource.substr(1);
            }
    
            if (hostType === 'module') {
    
                if (module.library) {
                    host = beyond.hosts.libraries[module.library.name].js;
                    library = module.library.name;
                }
                else {
                    host = beyond.hosts.application.js;
                    library = undefined;
                }
    
                modulePath = module.path;
                filePath = resource;
    
            }
            else if (hostType === 'application') {
    
                host = beyond.hosts.application.js;
                return host + resource;
    
            }
            else {
    
                var library = hostType;
                host = beyond.hosts.libraries[library];
    
                if (!host) {
                    console.warn('invalid css host on module "' + module.ID + '", resource "' + resource + '"' +
                        ', library "' + library + '" is not defined');
                    return;
                }
    
                if (resource.substr(0, 7) === 'static/') {
                    modulePath = 'main';
                    filePath = resource.substr(7);
                }
                else {
                    var overwrite = resource.split('/static/');
                    modulePath = overwrite[0];
                    filePath = overwrite[1];
                }
    
            }
    
            var overwrites = beyond.overwrites;
            var overwrited;
            if (library) {
                overwrited = overwrites[library];
            }
    
            if (!overwrited || !overwrited[modulePath] ||
                overwrited[modulePath].indexOf(filePath) === -1) {
    
                return host + modulePath + '/static/' + filePath;
            }
    
            return beyond.hosts.application.js +
                'custom/' + library + '/' +
                modulePath + '/static/' + filePath;
    
        };
    
        var setHosts = function (styles) {
    
            // find variables
            var variable;
    
            var replace = {};
    
            var regexp = /#host\.(.*?)#(.*?)[\)\s]/g;
            variable = regexp.exec(styles);
    
            var resource;
            while (variable) {
    
                // hostType can be 'application', 'module', libraryName
                var hostType = variable[1];
                resource = variable[2];
                resource = getResource(hostType, resource);
    
                var original = variable[0];
                if (original.substr(original.length - 1) === ')')
                    original = original.substr(0, original.length - 1);
    
                replace[original] = resource;
                variable = regexp.exec(styles);
    
            }
    
            // replace #host.* variables with their values
            for (var original in replace) {
    
                resource = replace[original];
    
                while (styles.indexOf(original) !== -1)
                    styles = styles.replace(original, resource);
    
            }
    
            return styles;
    
        };
    
        this.process = function (styles) {
    
            // find and replace #host...
            styles = setHosts(styles);
            return styles;
    
        };
    
    }
179238
function loadConfig(config, props) {
  // The calling module's path. Unfortunately, because modules are cached,
  // module.parent is the FIRST calling module parent, not necessarily the
  // current one.
  var callerPath = path.dirname(stackTrace.get(loadConfig)[1].getFileName());

  // If no config defined, resolve to nearest package.json to the calling lib. If not found, throw an error.
  if (config == null) {
    config = findup('package.json', {cwd: callerPath});
    if (config == null) {
      throw new Error('No package.json found.');
    }
  }
  // If filename was specified with no path parts, make the path absolute so
  // that resolve doesn't look in node_module directories for it.
  else if (typeof config === 'string' && !/[\\\/]/.test(config)) {
    config = path.join(callerPath, config);
  }

  // If package is a string, try to require it.
  if (typeof config === 'string') {
    config = require(resolve(config, {basedir: callerPath}));
  }

  // If config is not an object yet, something is amiss.
  if (typeof config !== 'object') {
    throw new Error('Invalid configuration specified.');
  }

  // For all specified props, populate result object.
  var result = {};
  props.forEach(function(prop) {
    result[prop] = config[prop] ? Object.keys(config[prop]) : [];
  });
  return result;
}
60168
async function getPkgInfo(pkgName) {
  if (typeof pkgName === 'object') {
    const info = {
      name: pkgName.name,
      basicName: pkgName.name,
      assets: {},
    };
    if (pkgName.scss) {
      info.assets.style = pkgName.scss;
      info.dir = path.dirname(pkgName.scss);
      ensureFileExists(pkgName.scss);
    }
    if (pkgName.js) {
      info.assets.main = pkgName.js;
      // yeah I know we're overwriting `dir`... got to have something though... and it's only used by PL to watch Twig
      info.dir = path.dirname(pkgName.js);
      ensureFileExists(pkgName.js);
    }
    return info;
  }

  if (pkgName.endsWith('.scss') || pkgName.endsWith('.js')) {
    const pathInfo = path.parse(pkgName);
    const name = pathInfo.name + pathInfo.ext.replace('.', '-');
    const info = {
      name,
      basicName: name,
      dir: path.dirname(pkgName),
      assets: {},
    };
    if (pkgName.endsWith('.scss')) {
      info.assets.style = pkgName;
    }
    if (pkgName.endsWith('.js')) {
      info.assets.main = pkgName;
    }
    ensureFileExists(pkgName);
    return info;
  } else {
    // package name
    const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
    const dir = path.dirname(pkgJsonPath);
    const pkg = require(pkgJsonPath);

    const info = {
      name: pkg.name,
      basicName: pkg.name.replace('@bolt/', 'bolt-'),
      dir,
      assets: {},
      deps: [],
    };

    if (pkg.peerDependencies) {
      for (dependencyPackageName in pkg.peerDependencies) {
        if (dependencyPackageName.includes('bolt')) {
          info.deps.push(dependencyPackageName);
        }
      }
    }

    if (pkg.dependencies) {
      for (dependencyPackageName in pkg.dependencies) {
        if (dependencyPackageName.includes('bolt')) {
          info.deps.push(dependencyPackageName);
        }
      }
    }

    info.twigNamespace = `@${info.basicName}`;
    if (pkg.style) {
      info.assets.style = path.join(dir, pkg.style);
      ensureFileExists(info.assets.style);
    }
    if (pkg.main) {
      info.assets.main = path.join(dir, pkg.main);
      ensureFileExists(info.assets.main);
    }
    if (pkg.schema) {
      if (typeof pkg.schema === 'object') {
        if (info.schema === undefined) {
          info.schema = [];
        }

        const schemas = pkg.schema;

        for (const schemaPath of schemas) {
          const schemaFilePath = path.join(dir, schemaPath);
          // eslint-disable-next-line
          const schema = await getDataFile(schemaFilePath);
          validateSchemaSchema(
            schema,
            `Schema not valid for: ${schemaFilePath}`,
          );
          const schemaMachineName = schema.title
            .replace(/ /g, '-')
            .toLowerCase();

          info.schema[schemaMachineName] = schema;
        }
      } else {
        const schemaFilePath = path.join(dir, pkg.schema);
        const schema = await getDataFile(schemaFilePath);
        validateSchemaSchema(schema, `Schema not valid for: ${schemaFilePath}`);
        info.schema = schema;
      }
    }
    // @todo Allow verbosity settings
    // console.log(assets);
    return info;
  }
}
215222
function() {

			// skip loading includes once already loaded
			if (this._bIncludesLoaded) {
				return;
			}

			var mResources = this.getEntry("/sap.ui5/resources");

			if (!mResources) {
				return;
			}

			var sComponentName = this.getComponentName();

			// load JS files
			var aJSResources = mResources["js"];
			if (aJSResources) {
				for (var i = 0; i < aJSResources.length; i++) {
					var oJSResource = aJSResources[i];
					var sFile = oJSResource.uri;
					if (sFile) {
						// load javascript file
						var m = sFile.match(/\.js$/i);
						if (m) {
							//var sJsUrl = this.resolveUri(sFile.slice(0, m.index));
							var sJsUrl = sComponentName.replace(/\./g, '/') + (sFile.slice(0, 1) === '/' ? '' : '/') + sFile.slice(0, m.index);
							Log.info("Component \"" + sComponentName + "\" is loading JS: \"" + sJsUrl + "\"");
							// call internal sap.ui.require variant that accepts a requireJS path and loads the module synchronously
							sap.ui.requireSync(sJsUrl);
						}
					}
				}
			}

			// include CSS files
			var aCSSResources = mResources["css"];
			if (aCSSResources) {
				for (var j = 0; j < aCSSResources.length; j++) {
					var oCSSResource = aCSSResources[j];
					if (oCSSResource.uri) {
						var sCssUrl = this.resolveUri(oCSSResource.uri);
						Log.info("Component \"" + sComponentName + "\" is loading CSS: \"" + sCssUrl + "\"");
						includeStylesheet(sCssUrl, {
							id: oCSSResource.id,
							"data-sap-ui-manifest-uid": this._uid
						});
					}
				}
			}

			this._bIncludesLoaded = true;

		}
1100463
function entrifyFromPkg(dir, options) {

  // Find package.json files.
  const pkgPaths = glob.sync('**/package.json', { cwd: dir, nodir: true, absolute: true })

  pkgPaths.forEach((pkgPath) => {
    console.log('[entrify]', 'Found:', pkgPath)
    const pkg = require(pkgPath)

    // A package.json file should have a main entry.
    if (!pkg.main) {
      console.warn('[entrify]', pkgPath, 'does not have a main entry.')
      return
    }

    // The main entry should not point to an index.js file.
    if (pkg.main === 'index.js' || pkg.main === './index.js') {
      console.warn('[entrify]', pkgPath, 'main entry is index.js.')
      return
    }

    // Ensure the index.js file to create doesn't already exist.
    const pkgDir = path.dirname(pkgPath)
    const indexPath = `${pkgDir}/index.js`

    if (fs.existsSync(indexPath)) {
      console.warn('[entrify]', indexPath, 'already exists.')
      return
    }

    // Create an index.js file alongside the package.json.
    const name = camelize(path.basename(pkgDir))
    const main = pkg.main.startsWith('./') ? pkg.main : `./${pkg.main}`

    fs.writeFileSync(indexPath, indexTemplate(options.format, { name, main }))
    console.log('[entrify]', indexPath, 'created!')

    // Delete the package.json file.
    fs.unlinkSync(pkgPath)
    console.log('[entrify]', pkgPath, 'deleted!')
  })
}