Have ideas to improve npm?Join in the discussion! »

    typhonjs-github-orgs-gulptasks

    0.0.7 • Public • Published

    typhonjs-github-orgs-gulptasks

    NPM Code Style License Gitter

    Build Status Dependency Status

    Provides GitHub many organization / repos gulp tasks shared by TyphonJS and beyond.

    The transform Gulp tasks are optional and only load if the following NPM modules are installed:

    The following are example entries in package.json:

      "dependencies": {
        "typhonjs-github-inspect-orgs": "^0.1.0"
        "typhonjs-github-inspect-orgs-transform": "^0.1.0"
      },
      "devDependencies": {
        "gulp": "^3.0.0",
        "typhonjs-github-orgs-gulptasks": "^0.1.0",
        "typhonjs-npm-build-test": "^0.1.0"
      },
    

    An example gulpfile.babel.js initializing the transform tasks:

    import fs            from 'fs';
    import gulp          from 'gulp';
    
    import gitGulpTasks  from 'typhonjs-github-orgs-gulptasks';
    
    // Import all GitHub Orgs gulp tasks
    
    // Loads owner / user public access tokens from environment variables or from `./token.owner` and `./token.user` in
    // the root directory.
    let ownerCredential = process.env.GITHUB_OWNER_TOKEN;
    let userCredential = process.env.GITHUB_USER_TOKEN;
    
    // If user ownerCredential is still undefined attempt to load from a local file `./owner.token`.
    if (typeof ownerCredential === 'undefined')
    {
       try { ownerCredential = fs.readFileSync('./token.owner', 'utf-8'); }
       catch(err) { /* ... */ }
    }
    
    // If user userCredential is still undefined attempt to load from a local file `./user.token`.
    if (typeof userCredential === 'undefined')
    {
       try { userCredential = fs.readFileSync('./token.user', 'utf-8'); }
       catch(err) { /* ... */ }
    }
    
    // Fail now if we don't have an owner token.
    if (typeof ownerCredential !== 'string')
    {
       throw new TypeError('No owner credentials found in `process.env.GITHUB_OWNER_TOKEN` or `./token.owner`.');
    }
    
    // Fail now if we don't have a user token.
    if (typeof userCredential !== 'string')
    {
       throw new TypeError('No user credentials found in `process.env.GITHUB_USER_TOKEN` or `./token.user`.');
    }
    
    // Defines TyphonJS organizations.
    const organizations = [{ credential: ownerCredential, owner: 'typhonrt', regex: '^typhonjs' }];
    
    // Import all tasks and set `rootPath` to the base project path and `srcGlob` to all JS sources in `./src`.
    gitGulpTasks(gulp,
    {
       rootPath: __dirname,
       importTasks: ['transform'],
       inspectOptions: { ctor: { organizations, verbose: true } },
       transformOptions: { ctor: { transformType: 'text' },  methods: { credential: userCredential } }
    });
    

    The above example Gulp file uses Babel / ES6 which is installed by typhonjs-npm-build-test. To configure the GitHub Orgs Gulp tasks a owner and user GitHub public access token containing public_repo and read:org permissions is either set as environment variables (useful for Travis CI testing) in process.env.GITHUB_OWNER_TOKEN and process.env.GITHUB_USER_TOKEN or in local files ./token.owner and ./token.user. It should be noted that if storing public access tokens in local files that the given project should include a .gitignore file that prevents checking them in as GitHub will invalidate those tokens if they are checked in as part of a commit.

    In particular regarding configuration please review:

    // Import all tasks and set `rootPath` to the base project path.
    gitGulpTasks(gulp,
    {
       rootPath: __dirname,
       importTasks: ['transform'],
       inspectOptions: { ctor: { organizations, verbose: true } },
       transformOptions: { ctor: { transformType: 'text' },  methods: { credential: userCredential } }
    });
    

    The second parameter to gitGulpTasks is an options hash that must contains:

    @param {object} options - Optional parameters:
    
    (object)          inspectOptions - Hash of options for GitHubInspectOrgs with following categories:
    
       (object)       ctor - Constructor options for GitHubInspectOrgs creation.
    
    (object)          transformOptions - Hash of options for GitHubInspectOrgsTransform with following categories:
    
       (object)       ctor - Constructor options for GitHubInspectOrgsTransform creation.
    
       (object)       methods - Options passed into GitHubInspectOrgsTransform method invocation. The `all` category of gulp tasks
                                defined will remove `credentials` entries.
    
       (object)       tasks - Options specific to controlling task creation below:
    
          (boolean)   skipNonCredentialTasks - If true then skip all tasks that don't require credentials.
    

    Please review the documentation for options available for:

    The following is a description of all imported Gulp tasks for typhonjs-github-inspect-orgs-transform with links to related documentation from typhonjs-github-inspect-orgs-transform:

    Install

    npm i typhonjs-github-orgs-gulptasks

    DownloadsWeekly Downloads

    9

    Version

    0.0.7

    License

    MPL-2.0

    Last publish

    Collaborators

    • avatar