structurizr / cli

A command line utility for Structurizr.
https://docs.structurizr.com/cli
Apache License 2.0
491 stars 75 forks source link

Structurizr CLI fails to properly push a workspace #72

Closed aizzi closed 2 years ago

aizzi commented 2 years ago

HOW TO REPRODUCE

1) Pull the latest CLI container

REPOSITORY         TAG       IMAGE ID       CREATED        SIZE
structurizr/cli    latest    f5607bde3feb   5 weeks ago    823MB

2) Create the following structure

.
├── architecture
│   ├── decisions
│   │   ├── 0001-record-architecture-decisions.md
│   │   └── 0002-second-decision.md
│   ├── documentation
│   │   ├── general
│   │   │   └── 01-introduction.md
│   │   └── system01
│   │       └── 01-introduction.md
│   ├── workspace.dsl
│   └── workspace.json

3) Create a simple workspace (note the multiple !docs statement)

workspace "Push Test" "A dummy workspace to test the push feature" {

    !docs documentation/general
    !adrs decisions

    model {
        ss_system01 = softwareSystem "System 01" {
            !docs documentation/system01
            description "A dummy system to test the documentation"
        }
    }

    views {
        theme default

        systemLandscape "dgm01" "This is the landscape diagram" {
            title "DGM01: Landscape"
            include *
            autolayout "lr"
        }
    }
}

3) Create the documentation file documentation/general/01-introduction.md

## General Documentation

This is an example of general documentation

4) Create the documentation file documentation/system01/01-introduction.md

## Introduction

This is the documentation for the System01

5) Create two decisions using the adr tool

6) Start Structurizr Lite. The workspace, the documentation and the decisions are rendered properly locally

7) Now create a new workspace in the Structurizr Cloud and push the workspace.json to it (the command is executed from the root of the filesystem):

~/SourceCode/structurizr-test$ docker run -it --rm -v $PWD:/usr/local/structurizr structurizr/cli push -workspace architecture/workspace.json -id ##### -key ########-####-#########-############ -secret ########-####-####-####-############
Pushing workspace 73119 to https://api.structurizr.com
 - creating new workspace
 - parsing model and views from /usr/local/structurizr/architecture/workspace.json
 - merge layout from remote: true
 - storing previous version of workspace in architecture
 - pushing workspace
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Mar 29, 2022 3:15:38 PM com.structurizr.api.StructurizrClient getWorkspace
INFO: Getting workspace with ID 73119
Mar 29, 2022 3:15:38 PM com.structurizr.api.StructurizrClient putWorkspace
INFO: Putting workspace with ID 73119
Mar 29, 2022 3:15:39 PM com.structurizr.api.StructurizrClient putWorkspace
INFO: {"success":true,"message":"OK","revision":2}
 - finished

8) The workspace in the Cloud is not properly rendered. Specifically:

9) Now configure the workspace for auto-sync, by adding the structurizr.properties:

.
├── architecture
│   ├── decisions
│   │   ├── 0001-record-architecture-decisions.md
│   │   └── 0002-second-decision.md
│   ├── documentation
│   │   ├── general
│   │   │   └── 01-introduction.md
│   │   └── system01
│   │       └── 01-introduction.md
│   ├── structurizr.properties       <=======
│   ├── workspace.dsl
│   └── workspace.json

10) Stop the "Structurizr Lite" container to trigger the autosync.

~/SourceCode/structurizr-test$ docker stop structurizr-test
structurizr-test

11) This time the workspace on Cloud is properly rendered:

simonbrowndotje commented 2 years ago

I've just tried to reproduce the issue with this workspace and everything seems okay to me. In step 7, have you tried pushing the workspace.dsl file rather than the workspace.json file? And are you running the latest version of Structurizr Lite?

aizzi commented 2 years ago
simonbrowndotje commented 2 years ago

In that case, are you sure that the workspace.json file corresponded to the content defined by the workspace.dsl file at the time it was pushed with the CLI? There are some times when opening a workspace in Lite doesn't necessarily create a workspace.json file.

aizzi commented 2 years ago

For what I can say, yes. This is it:

{
  "id" : 1,
  "name" : "Push Test",
  "description" : "A dummy workspace to test the push feature",
  "lastModifiedDate" : "2022-03-30T08:47:01Z",
  "properties" : {
    "structurizr.dsl" : "d29ya3NwYWNlICJQdXNoIFRlc3QiICJBIGR1bW15IHdvcmtzcGFjZSB0byB0ZXN0IHRoZSBwdXNoIGZlYXR1cmUiIHsKCiAgICAhZG9jcyBkb2N1bWVudGF0aW9uL2dlbmVyYWwKICAgICFhZHJzIGRlY2lzaW9ucwoKICAgIG1vZGVsIHsKICAgICAgICBzc19zeXN0ZW0wMSA9IHNvZnR3YXJlU3lzdGVtICJTeXN0ZW0gMDEiIHsKICAgICAgICAgICAgIWRvY3MgZG9jdW1lbnRhdGlvbi9zeXN0ZW0wMQogICAgICAgICAgICBkZXNjcmlwdGlvbiAiQSBkdW1teSBzeXN0ZW0gdG8gdGVzdCB0aGUgZG9jdW1lbnRhdGlvbiIKICAgICAgICB9CiAgICB9CgogICAgdmlld3MgewogICAgICAgIHRoZW1lIGRlZmF1bHQKCiAgICAgICAgc3lzdGVtTGFuZHNjYXBlICJkZ20wMSIgIlRoaXMgaXMgdGhlIGxhbmRzY2FwZSBkaWFncmFtIiB7CiAgICAgICAgICAgIHRpdGxlICJER00wMTogTGFuZHNjYXBlIgogICAgICAgICAgICBpbmNsdWRlICoKICAgICAgICAgICAgYXV0b2xheW91dCAibHIiCiAgICAgICAgfQogICAgfQp9Cg=="
  },
  "configuration" : { },
  "model" : {
    "softwareSystems" : [ {
      "id" : "1",
      "tags" : "Element,Software System",
      "name" : "System 01",
      "description" : "A dummy system to test the documentation",
      "location" : "Unspecified",
      "documentation" : {
        "sections" : [ {
          "title" : "Introduction",
          "content" : "## Introduction\n\nThis is the documentation for the System01\n",
          "format" : "Markdown",
          "order" : 1
        } ]
      }
    } ]
  },
  "documentation" : {
    "sections" : [ {
      "title" : "General Documentation",
      "content" : "## General Documentation\n\nThis is an example of general documentation\n",
      "format" : "Markdown",
      "order" : 1
    } ],
    "decisions" : [ {
      "title" : "Record architecture decisions",
      "content" : "# 1. Record architecture decisions\n\nDate: 2022-03-29\n\n## Status\n\nAccepted\n\n## Context\n\nWe need to record the architectural decisions made on this project.\n\n## Decision\n\nWe will use Architecture Decision Records, as [described by Michael Nygard](http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisions).\n\n## Consequences\n\nSee Michael Nygard's article, linked above. For a lightweight ADR toolset, see Nat Pryce's [adr-tools](https://github.com/npryce/adr-tools).\n",
      "format" : "Markdown",
      "id" : "1",
      "date" : "2022-03-29T00:00:00Z",
      "status" : "Accepted"
    }, {
      "title" : "second decision",
      "content" : "# 2. second decision\n\nDate: 2022-03-30\n\n## Status\n\nProposed\n\n## Context\n\nThe issue motivating this decision, and any context that influences or constrains the decision.\n\n## Decision\n\nThe change that we're proposing or have agreed to implement.\n\n## Consequences\n\nWhat becomes easier or more difficult to do and any risks introduced by the change that will need to be mitigated.\n",
      "format" : "Markdown",
      "id" : "2",
      "date" : "2022-03-30T00:00:00Z",
      "status" : "Proposed"
    } ]
  },
  "views" : {
    "systemLandscapeViews" : [ {
      "description" : "This is the landscape diagram",
      "key" : "dgm01",
      "order" : 1,
      "automaticLayout" : {
        "implementation" : "Graphviz",
        "rankDirection" : "LeftRight",
        "rankSeparation" : 300,
        "nodeSeparation" : 300,
        "edgeSeparation" : 0,
        "vertices" : false
      },
      "title" : "DGM01: Landscape",
      "enterpriseBoundaryVisible" : true,
      "elements" : [ {
        "id" : "1",
        "x" : 0,
        "y" : 0
      } ]
    } ],
    "configuration" : {
      "branding" : { },
      "styles" : { },
      "themes" : [ "https://static.structurizr.com/themes/default/theme.json" ],
      "terminology" : { },
      "lastSavedView" : "dgm01"
    }
  }
}

When I push this JSON, I get only the "general documentation:. I miss the one inside the software system "Sytem 01".

If I open the same workspace in Lite, everything is fine. And the autosync from Lite works perfectly.

simonbrowndotje commented 2 years ago

Lite has been running a new version of the Structurizr for Java library for a couple of weeks, but the CLI hasn't been updated until today. Updating the CLI docker image should resolve this for you.

aizzi commented 2 years ago

Confirmed. Latest CLI version solved the problem. Thank you.

structurizr/cli latest 972646a853cf 5 hours ago 635MB