Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WiP) PR: Gracfully Deprecation of the Package in favor of npm - The Final Commit! #1202

Open
1 of 9 tasks
Tracked by #1
frank-dspeed opened this issue Aug 23, 2022 · 2 comments
Open
1 of 9 tasks
Tracked by #1

Comments

@frank-dspeed
Copy link
Contributor

WiP PR transition to NPM 8 Gracefull Deprecation

Detailed Roadmap is supplyed in Expected Result. All Algos from this got adopted into the npm core package via its modules i am from the NodeJS Package Maintainance Group i would want to guide you trough the process of Deprecation if you allow me to do so.

I Was always a big fan of this project but the patterns did now improve and we got total new workflows but still all the functionality in here can be translated to npm now.

I Summon @justinbmeyer @matthewp @cherifGsoul to review and track this Issue and the PR that will Close it Thanks for all the wunderfull years this Project was a big influence for me.

But as NPM 8 now ships with lts its time to say good bye at last to this package.

How often can you reproduce it?

  • Always
  • Sometimes
  • Rarely
  • Unable
  • I didn’t try

Description:

Steps to reproduce:

  1. Include a JS Bin (or equivalent) link if possible
  2. Detail the exact steps taken to produce the problem
  3. Include a gif if possible; you can use LICEcap to make a gif: http://www.cockos.com/licecap/

Expected results:

  • - Should work again using the npm package modules
  • - Make Deprecation Warning and guide to the new command with npm
  • - Add all-contributors list to README
  • - Archive the Repo as if that api breaks migration guide will be on npmjs.com

Actual results:

Environment:

Software Version
donejs -V "deprecation_npm"
node -v "node": "^12.13.0
npm -v "version": "8"
Browser
Operating system
@frank-dspeed
Copy link
Contributor Author

frank-dspeed commented Aug 23, 2022

Notes

Docs update all guides need migration consider automation via @stealify/stealify PackageMaintainance Tools

should get released in all x.x.x so backporting as old does not work anymore anyway. also deprecation of all it adds no benefits to keep that alive as it is a cli tool and the ssl version of older node does not even connect anymore to any cloudflare site so its save to do this.

npm install -g donejs 
donejs add app my-app
## Bad algo but only to show what it does
mkdir -p my-app
cd my-app
npm init
npm i -D generator-donejs@^3.0.0 donejs-cli

Internal FunFact

npx got replaced by the same methods it internal now uses npm exec read more in the npm docs

Generators

When running donejs add DoneJS will

  • Check if donejs- is installed locally
  • If not, install it from npm
  • Then run the generator at default/index.js
npm i -D donejs-<generatorname>

General Translation

// Note execSync auto uses process.cwd()
const { execSync: exec } = await import(''node:child_process)
const projectRoot = exec('npm prefix');
const projectModules = exec('npm root');
const globalModules = exec('npm root -g');

// TODO: Should always use local one import('yeoman')
const globalInstalledYo = `${globalModules}/yeoman`

// Utils
const installIfMissing = (specifier) => import(specifier).catch(()=>exec(`npm i -D ${specifier}`))

donejs/donejs/cli add

var cmdInit = require('./cmd-init');
var runBinary = require('./run-binary');
var types = ['app', 'plugin', 'generator'];

// `donejs add app [folder]`       => `donejs-cli init [folder]`
// `donejs add plugin [folder]`    => `donejs-cli init [folder] --type=plugin`
// `donejs add generator [name]`   => `donejs-cli init [folder] --type=generator`

// `donejs add <name> [params...]` => `donejs-cli add <name> [params...]`
module.exports = function(type, params, options) {

  // handles commands with the following shape `donejs add <type> [folder]`
  if (types.indexOf(type) !== -1) {
    var folder = params[0];

    if (type !== 'app') {
      options.type = type;
    }

    return cmdInit(folder, options);
  }
  // handles commands with the following shape `donejs add <name> [params...]`
  else {
    var args = ['add', type].concat(params);
    return runBinary(args, options, types);
  }
};

====

// donejs/cli 
// `donejs add app [folder]`       => `donejs-cli init [folder]`
// `donejs add plugin [folder]`    => `donejs-cli init [folder] --type=plugin`
// `donejs add generator [name]`   => `donejs-cli init [folder] --type=generator`
// `donejs add <name> [params...]` => `donejs-cli add <name> [params...]`
const add = {
  var generators = require(path.join(root, 'node_modules', 'generator-donejs'));

  if (generators[name]) {
    debug('add called but running generate instead', name, params);
    return generate(root, name, params);
  }

  debug('add', name, params);
  return add(path.join(root, 'node_modules'), name, params);
// new  
 generate(projectModules, 'donejs-' +generatorName, (params && params.length) ? params : ['default'])

// donejs cli util
exports.add = function(root, name, params) {
  var generatorName = 'donejs-' + name;
  params = (params && params.length) ? params : ['default'];

  debug('Adding', generatorName, params);
  return generate(root, generatorName, params);
  // New
  generate(root, 'donejs-' + name, (params && params.length) ? params : ['default'])
};

// Run any of the Yeoman generators from the current generator-donejs
var generate = exports.generate = function(root, generator, args) {
  var generatorName = generator.split('@')[0];

  return Q.resolve(installIfMissing(root, generator)())
    .then(function () {
      var generators = require(path.join(root, generatorName));
      var env = yeoman.createEnv();

      Object.keys(generators).forEach(function(name) {
          var fullName = path.join(root, generatorName, name);
          debug('Registering generator', fullName);
          env.register(require.resolve(fullName), name);
      });

      return Q.npost(env, 'run', args);
    });
};

commands

The following commands are available. To initialize a new DoneJS related project:

donejs add app [projectname] create a new DoneJS application
donejs add plugin [projectname] create a new DoneJS plugin
donejs add generator [projectname] create a new generator project

Within a DoneJS application or plugin:

donejs add component to create a CanJS component
donejs add supermodel to create a can-connect connection
donejs add module to generate a general purpose modlet

the donejs-generator contains

// is what we get as generators
exports.app = require('../app/index');
exports.plugin = require('../plugin/index');
exports.generator = require('../generator/index');

exports.component = require('../component/index');
exports.supermodel = require('../supermodel/index');
exports.module = require('../module/index');

npm set init-author-email "example-user@example.com"
npm set init-author-name "example_user"
npm set init-license "Apache-2.0"

@frank-dspeed
Copy link
Contributor Author

//cli utils
// eq Promise.resolve(child_process.execSync)
runCommand = exports.runCommand = function(cmd, args) {

TODO

exports.runScript = function(name, args) {
  debug('Running npm script', name, args);
  return runCommand('npm', ['run', name].concat(args || []));
};

// Log error messages and exit application
exports.log = function(promise) {
  return promise.then(function() {
    process.exit(0);
  }, function(error) {
    console.error(error.stack || error.message || error);
    process.exit(1);
  });
};

exports.npmVersion = function(){
    var child = spawn('npm', ['--version'], {
    cwd: process.cwd()
  });

  var deferred = Q.defer();
  var version = '';
  var getVersion = function(d){
    version = d.toString();
  };

  child.stdout.on('data', getVersion);

  child.on('exit', function() {
    var parts = version.trim().split(".");
    deferred.resolve({
      major: +parts[0],
      minor: +parts[1],
      patch: parts[1]
    });
  });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant