scheibome / kss-scheibo

KSS-Scheibo - a template for the KSS-node styleguide
https://kss-scheibo.scheibitz.com/
MIT License
7 stars 2 forks source link

Version 1.8.9 breaks grunt-kss build #12

Closed hirnschmalz closed 2 years ago

hirnschmalz commented 2 years ago

After an upgrade to the latest version of this package the build process with grunt-kss fails

Running "kss:dist" (kss) task
Error: kss expected the builder to implement KssBuilderBase API version 3.0; version "3.0" is being used instead.
scheibome commented 2 years ago

Can you install an older version of kss-scheibo and tell me in which version it still worked?

hirnschmalz commented 2 years ago

It works with version 1.8.8

scheibome commented 2 years ago

I just built a test setup and tested different versions and I get the error in each version. Can you test the setup on your end and confirm that it works for you without error?

I can now reproduce a running version after all. I'll see what the problem is.

scheibome commented 2 years ago

I have found the problem, however I cannot give you a solution within KSS-Scheibo.

The problem is that KSS-Scheibo was using the latest version of KSS, which is now at version 3.1. Grunt-kss got the last update 5 years ago and the dependency is still on KSS version 3.0

Grunt-kss uses checks in its own builder for the version of the builder and then gives this error message if it does not match.

To test this you can delete the package-lock.json in your project, then change to the folder ./node_modules/grunt-kss and execute npm i kss@latest. Then go back to your project root and run npm install and see if the error message still appears.

The only possibility I see is that in the Grunt-kss packages the dependency is also increased to the current version of KSS 3.1.

As a workaround you could create a fork of grunt-kss and update the dependency here and then load this package in your project.

scheibome commented 2 years ago

Or even simpler, you remove the unnecessary grunt-kss and copy the task from the package into your own tasks. This is in my opinion the best way, because grunt-kss does no real magic.

Something like this:

var kss = require('kss');

module.exports = function(grunt) {
    grunt.initConfig({
        kss: {
            options: {
                verbose: true,
                builder: 'node_modules/kss-scheibo/kss_styleguide/scheibo-template/',
                custom: ["Colors", "Wrapper", "RequireJS", "BodyClass", "HtmlLang"]
            },
            dist: {
                src: ['./testfiles/sourcedir'],
                dest: './testfiles/destdir'
            }
        }
    });

    grunt.registerMultiTask('kss', 'Generate style guide with KSS.', function() {

        var done = this.async();

        var options = this.options({});

        // Add source and destination from Grunt.
        options.source = [];
        this.files.forEach(function(file) {
            options.destination = file.dest;
            for (var i = 0; i < file.src.length; i++) {
                options.source.push(file.src[i]);
            }
        });

        // Use promise to make sure done() is called when kss() ends
        kss(options).then(function() {
            done();
        }).catch(function(error) {
            done(error);
        });
    });
};