Constructor for Package

@param {string} name
545350
function Package(name)
    {
        var dotBowerJson = Package._readBowerJson(name) || {};
        var overrides = globalOverrides[name] || {};

        this.name         = name;
        this.installed    = !! dotBowerJson.name;
        this.main         = overrides.main || dotBowerJson.main || [];
        this.dependencies = overrides.dependencies || dotBowerJson.dependencies || [];
    }
809434
function (name) {
    if (!this.instances[name]) {
      this.instances[name] = DevFixturesModel.create({name: name});
    }
    return this.instances[name];
  }
201357
function( name, method ) {
			var m = this.settings.messages[name];
			return m && (m.constructor === String ? m : m[method]);
		}
1042345
def create(self, name, data=None):
        
        return createPacket(self[name], data) if name in self else None
730723
function (parent,config,modulePath,npmPath,classesSource)
	{
		this.e.log&&this.e.log('Constructing new `'+this.className+'`...','system');

		if (modulePath==undefined)
			modulePath = cwd;

		try {
			this.setParent(parent);
		} catch (e)
		{
			if (e)
				console.log(this);
		}

		this.setModulePath(path.resolve(path.resolve(parent.modulePath,modulePath))+'/');

		this.preinit.apply(this,arguments); 

		this.npmPath = npmPath || [];
		this.importClasses(classesSource);

		var defaultConfig = cwd+sourcePath+'config/'+className.split('_')[0]+'Config.json';
		if (fs.existsSync(defaultConfig))
			this.configureFromFile(defaultConfig);
		if (fs.existsSync(this.modulePath + this.configFile))
			this.configureFromFile(this.modulePath + this.configFile);
		if (config)
			this.setConfig(config);

		_debug = this.getConfig('debug')===true;

		this.importPackages();
		this.importFromConfig();

		Object.defineProperty(this,'c',{ value: this.getComponent('classBuilder').classes, enumerable:false, writable: false });
		this.c.module = self;

		this.preloadEvents();
		this.preloadComponents();

		this.setEvents({ 'ready': {} });
		var ready=this.getEvent('ready');
		ready.once(function (e) {
			self.startComponents();
			self.prepareModels();
			self.prepareScripts();

			self.init.apply(self,arguments);
			self.run.apply(self,arguments);
			_initialized=true;
		});
	}
827939
function CreateStatelet(name, obj) {

    var m_Api = {};
    m_Api.getName = function () {
        return name;
    };

    m_Api.execute = function(builder, db, route) {

        if(obj.dependencies !== undefined) {
            // loop thru and wait
            return Promise.all(obj.dependencies.map(function(depend) {
                return builder.get(depend);
            })).then(function(args) {
                return obj.process.apply(obj, [builder, db, route].concat(args));
            });
        }

        return obj.process(builder, db, route);
    };

    return m_Api;
}
91109
function normalizePackageName(name, prefix) {
    let normalizedName = name;

    /**
     * On Windows, name can come in with Windows slashes instead of Unix slashes.
     * Normalize to Unix first to avoid errors later on.
     * https://github.com/eslint/eslint/issues/5644
     */
    if (normalizedName.indexOf("\\") > -1) {
        normalizedName = pathUtils.convertPathToPosix(normalizedName);
    }

    if (normalizedName.charAt(0) === "@") {

        /**
         * it's a scoped package
         * package name is the prefix, or just a username
         */
        const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"),
            scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u");

        if (scopedPackageShortcutRegex.test(normalizedName)) {
            normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
        } else if (!scopedPackageNameRegex.test(normalizedName.split("/")[1])) {

            /**
             * for scoped packages, insert the prefix after the first / unless
             * the path is already @scope/eslint or @scope/eslint-xxx-yyy
             */
            normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
        }
    } else if (normalizedName.indexOf(`${prefix}-`) !== 0) {
        normalizedName = `${prefix}-${normalizedName}`;
    }

    return normalizedName;
}
369766
function( packageFilename, options ) {
    if( typeof options === 'undefined' ) options = {};

    packageFilename = Path.resolve( packageFilename );
    if( false == FS.existsSync() ) 
        this.fatal( "Package file not found: \"" + packageFilename + "\"" );
    
    var prjDir = Path.dirname( packageFilename );
    this._prjDir = Path.resolve( prjDir );
    this._libDir = Path.resolve( Path.join(__dirname, "../ker") );
    this._tplDir = Path.resolve( Path.join(__dirname, "../tpl") );
    this._srcDir = mkdir.call( this, prjDir, "src" );
    this._docDir = mkdir.call( this, prjDir, "doc" );
    this._tmpDir = mkdir.call( this, prjDir, "tmp" );
    this._wwwDir = mkdir.call( this, prjDir, "www" );

}
348595
function Class(name,options) {

  this.name = name || "";
  this.mixins = [];
  this.methods = {};
  this.properties = {};

  if (lib.type.isObject(options)) {
    var keys = Object.keys(options);
    var length = keys.length;
    for (var i = 0; i < length; i++) {
      var key = keys[i];
      var value = options[key];
      if (key === "constructor") {
        this.addConstructor(value);
      } else if (key === "inherits") {
        this.inherit(value);
      } else if (key === "mixins") {
        this.mixin(value);
      } else if (lib.type.isFunction(value) && lib.inherits.superOf(value,Property)) {
        this.addProperty(key,value);
      } else {
        this.addMethod(key,value);
      }
    }
  }

}
1196222
function (skyPagesConfig) {
    let name = '';

    if (skyPagesConfig.skyux.name) {
      name = skyPagesConfig.skyux.name;
    } else {

      const packagePath = this.spaPath('package.json');
      const packageJson = fs.existsSync(packagePath) ? readConfig(packagePath) : {};

      if (packageJson.name) {
        name = packageJson.name;
      } else {
        logger.error('The `name` property should exist in package.json or skyuxconfig.json');
      }
    }

    return '/' + name.replace(/blackbaud-skyux-spa-/gi, '') + '/';
  }
321350
function npmInstall(packageName)
{
    return new Promise((resolve,reject) => {
        
        npm.load({
            save:false,
			progress: false,
            force:true
        }, function (er) {
            if (er)
            {
                PAILogger.error(er);
				return reject(er);
			}
            
            npm.commands.install([packageName], function (er, data) {
                if (er) {
					PAILogger.error(er);
					return reject(er);
                }
                resolve(data);
                // command succeeded, and data might have some info
            });
            
        });
        
    });
}
1189182
public static Matcher constructor(final String name) {
    return new Matcher() {
      @Override public boolean matches(Node node, NodeMetadata metadata) {
        JSDocInfo info = node.getJSDocInfo();
        if (info != null && info.isConstructor()) {
          Node firstChild = node.getFirstChild();
          // TODO(mknichel): Make sure this works with the following cases:
          // ns = {
          //   /** @constructor */
          //   name: function() {}
          // }
          if (name == null) {
            return true;
          }
          if ((firstChild.isGetProp() || firstChild.isName())
              && firstChild.matchesQualifiedName(name)) {
            return true;
          }
        }
        return false;
      }
    };
  }
1225988
function configure(pkg, location, env, target) {
  const isProd = env === "production";
  const isUmd = target === "umd";
  const isModule = target === "module";
  const input = fs.existsSync(`${location}/src/index.js`)
    ? `${location}/src/index.js`
    : `${location}/src/index.ts`;
  const watch = {
    chokidar: true,
    include: `${location}/src/**`,
    exclude: `${location}/node_modules/**`
  };

  const isTypescript = /\.(ts|tsx)$/i.test(input);

  const deps = []
    .concat(pkg.dependencies ? Object.keys(pkg.dependencies) : [])
    .concat(pkg.peerDependencies ? Object.keys(pkg.peerDependencies) : []);

  const plugins = [
    // Allow Rollup to resolve modules from `node_modules`, since it only
    // resolves local modules by default.
    resolve({
      browser: true,
      preferBuiltins: true
    }),

    eslint({}),

    // Allow Rollup to resolve CommonJS modules, since it only resolves ES2015
    // modules by default.
    isUmd &&
      commonjs({
        exclude: [`${location}/src/**`],
        // HACK: Sometimes the CommonJS plugin can't identify named exports, so
        // we have to manually specify named exports here for them to work.
        // https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports
        namedExports: {
          esrever: ["reverse"],
          immutable: [
            "List",
            "Map",
            "Record",
            "OrderedSet",
            "Set",
            "Stack",
            "is"
          ],
          "fbjs/lib/shallowEqual": ["shallowEqual"],
          react: ["createElement", "Component"],
          "react-dom": ["findDOMNode"],
          "react-dom/server": ["renderToStaticMarkup"]
        }
      }),

    // Convert JSON imports to ES6 modules.
    json(),

    // Replace `process.env.NODE_ENV` with its value, which enables some modules
    // like React and Slate to use their production variant.
    replace({
      "process.env.NODE_ENV": JSON.stringify(env)
    }),

    isTypescript &&
      typescript({
        tsconfig: `${location}/tsconfig.rollup.json`,
        typescript: require("typescript"),
        useTsconfigDeclarationDir: true,
        tsconfigOverride: {
          compilerOptions: {
            rootDir: path.resolve(location, "src")
          },
          include: [path.resolve(location, "src")]
        }
      }),

    // Use Babel to transpile the result, limiting it to the source code.
    !isTypescript &&
      babel({
        include: [`${location}/src/**`],
        plugins: ["@babel/external-helpers"]
      }),

    // Register Node.js globals for browserify compatibility.
    globals(),
    analyze({
      writeTo: string => {
        fs.writeFileSync(`tmp/stats/${pkg.name}-${target}-${env}.txt`, string);
      }
    }),

    // Only minify the output in production, since it is very slow. And only
    // for UMD builds, since modules will be bundled by the consumer.
    isUmd &&
      isProd &&
      terser({
        parse: {
          ecma: 8
        },
        compress: {
          ecma: 5,
          warnings: false,
          comparisons: false,
          inline: 2
        },
        mangle: {
          safari10: true
        },
        output: {
          ecma: 5,
          comments: false,
          ascii_only: true
        }
      })
    // progress()
  ].filter(Boolean);

  if (isUmd) {
    return {
      watch,
      plugins,
      input,
      output: {
        format: "umd",
        file: `${location}/${isProd ? pkg.umdMin : pkg.umd}`,
        exports: "named",
        name: startCase(pkg.name)
          .replace(/@vericus/g, "")
          .replace(/ /g, ""),
        globals: pkg.umdGlobals,
        sourcemap: true
      },
      external: Object.keys(pkg.umdGlobals || {})
    };
  }

  if (isModule) {
    return {
      watch,
      plugins,
      input,
      output: [
        {
          file: `${location}/${pkg.module}`,
          format: "es",
          sourcemap: true
        },
        {
          file: `${location}/${pkg.main}`,
          format: "cjs",
          exports: "named",
          sourcemap: true
        }
      ],
      // We need to explicitly state which modules are external, meaning that
      // they are present at runtime. In the case of non-UMD configs, this means
      // all non-Slate-kit packages.
      external: id => !!deps.find(dep => dep === id || id.startsWith(`${dep}/`))
    };
  }
  return undefined;
}
924883
function init (options) {
  if (typeof options === 'string') {
    options = { base: options }
  }

  options = options || {}

  // There is probably 99% chance that the project root directory in located
  // above the node_modules directory
  var base = nodePath.resolve(
    options.base || nodePath.join(__dirname, '../..')
  )
  var packagePath = base.replace(/\/package\.json$/, '') + '/package.json'

  try {
    var npmPackage = require(packagePath)
  } catch (e) {
    // Do nothing
  }

  if (typeof npmPackage !== 'object') {
    throw new Error('Unable to read ' + packagePath)
  }

  //
  // Import aliases
  //

  var aliases = npmPackage._moduleAliases || {}

  for (var alias in aliases) {
    if (aliases[alias][0] !== '/') {
      aliases[alias] = nodePath.join(base, aliases[alias])
    }
  }

  addAliases(aliases)

  //
  // Register custom module directories (like node_modules)
  //

  if (npmPackage._moduleDirectories instanceof Array) {
    npmPackage._moduleDirectories.forEach(function (dir) {
      if (dir === 'node_modules') return

      var modulePath = nodePath.join(base, dir)
      addPath(modulePath)
    })
  }
}
554166
function npmInstall(packages, callback) {
  callback = utils.defineCallback(callback);
  if (_.isString(packages)) {
    packages = [ packages ];
  }
  return npm.load({
    loglevel: "silent",
    prefix: tmpDir,
  }, function(loadErr) {
    if (loadErr) {
      return callback(new errors.NpmLoadError(loadErr));
    }
    npm.commands.install(packages, function(installErr) {
      if (installErr) {
        return callback(new errors.NpmInstallError(installErr));
      }
      ncp(tmpDir + "/node_modules/", pluginsDir, function(copyError) {
        if (copyError) {
          return callback(new errors.PluginsMoveFromTempError(copyError));
        }
        return callback(null);
      }); // ncp
    }); // npm.commands.install
  }); // npm.load
}
261334
function(loader, name){
		var pkg = utils.pkg.findByName(loader, name.split("/")[0]);
		if(pkg) {
			var parsed = utils.moduleName.parse(name, pkg.name);
			parsed.version = pkg.version;
			if(!parsed.modulePath) {
				parsed.modulePath = utils.pkg.main(pkg);
			}
			return utils.moduleName.create(parsed);
		}
		return name;
	}
987050
function createWebpack ({ alias = {}, context, name = 'index' }) {
  const pkgJson = require(path.join(context, 'package.json'));
  const ENV = process.env.NODE_ENV || 'development';
  const isProd = ENV === 'production';
  const hasPublic = fs.existsSync(path.join(context, 'public'));
  const plugins = hasPublic
    ? [new CopyWebpackPlugin([{ from: 'public' }])]
    : [];

  return {
    context,
    devtool: isProd ? 'source-map' : 'cheap-eval-source-map',
    entry: [
      `./src/${name}.tsx`,
      isProd
        ? null
        : 'webpack-plugin-serve/client'
    ].filter((entry) => entry),
    mode: ENV,
    output: {
      chunkFilename: `[name].[chunkhash:8].js`,
      filename: `[name].[hash:8].js`,
      globalObject: `(typeof self !== 'undefined' ? self : this)`,
      path: path.join(context, 'build')
    },
    resolve: {
      alias,
      extensions: ['.js', '.jsx', '.ts', '.tsx']
    },
    module: {
      rules: [
        {
          test: /\.css$/,
          exclude: /(node_modules)/,
          use: [
            isProd
              ? MiniCssExtractPlugin.loader
              : require.resolve('style-loader'),
            {
              loader: require.resolve('css-loader'),
              options: {
                importLoaders: 1
              }
            },
            {
              loader: require.resolve('postcss-loader'),
              options: {
                ident: 'postcss',
                plugins: () => [
                  require('precss'),
                  require('autoprefixer'),
                  require('postcss-simple-vars'),
                  require('postcss-nested'),
                  require('postcss-import'),
                  require('postcss-clean')(),
                  require('postcss-flexbugs-fixes')
                ]
              }
            }
          ]
        },
        {
          test: /\.css$/,
          include: /node_modules/,
          use: [
            isProd
              ? MiniCssExtractPlugin.loader
              : require.resolve('style-loader'),
            require.resolve('css-loader')
          ]
        },
        {
          test: /\.(js|ts|tsx)$/,
          exclude: /(node_modules)/,
          use: [
            require.resolve('thread-loader'),
            {
              loader: require.resolve('babel-loader'),
              options: require('@polkadot/dev-react/config/babel')
            }
          ]
        },
        {
          test: /\.md$/,
          use: [
            require.resolve('html-loader'),
            require.resolve('markdown-loader')
          ]
        },
        {
          test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
          use: [
            {
              loader: require.resolve('url-loader'),
              options: {
                limit: 10000,
                name: 'static/[name].[hash:8].[ext]'
              }
            }
          ]
        },
        {
          test: [/\.eot$/, /\.ttf$/, /\.svg$/, /\.woff$/, /\.woff2$/],
          use: [
            {
              loader: require.resolve('file-loader'),
              options: {
                name: 'static/[name].[hash:8].[ext]'
              }
            }
          ]
        }
      ]
    },
    node: {
      child_process: 'empty',
      dgram: 'empty',
      fs: 'empty',
      net: 'empty',
      tls: 'empty'
    },
    optimization: {
      runtimeChunk: 'single',
      splitChunks: {
        cacheGroups: {
          vendorOther: {
            chunks: 'initial',
            enforce: true,
            name: 'vendor',
            test: /node_modules\/(asn1|bn\.js|buffer|cuint|elliptic|lodash|moment|readable-stream|rxjs)/
          },
          vendorReact: {
            chunks: 'initial',
            enforce: true,
            name: 'react',
            test: /node_modules\/(chart|i18next|react|semantic-ui)/
          },
          polkadotJs: {
            chunks: 'initial',
            enforce: true,
            name: 'polkadotjs',
            test: /node_modules\/(@polkadot\/wasm-(crypto|dalek-ed25519|schnorrkel))/
          }
        }
      }
    },
    performance: {
      hints: false
    },
    plugins: plugins.concat([
      new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
      new webpack.DefinePlugin({
        'process.env': {
          NODE_ENV: JSON.stringify(ENV),
          VERSION: JSON.stringify(pkgJson.version),
          WS_URL: JSON.stringify(process.env.WS_URL)
        }
      }),
      new HtmlWebpackPlugin({
        inject: true,
        template: path.join(context, `${hasPublic ? 'public/' : ''}${name}.html`),
        PAGE_TITLE: 'Polkadot/Substrate Portal'
      }),
      new webpack.optimize.SplitChunksPlugin(),
      new MiniCssExtractPlugin({
        filename: `[name].[contenthash:8].css`
      }),
      isProd
        ? null
        : new WebpackPluginServe({
          port: 3000,
          static: path.join(process.cwd(), '/build')
        })
    ]).filter((plugin) => plugin),
    watch: !isProd
  };
}