Skip to content

Commit

Permalink
dev : uncomment NEXT_PUBLIC_URI by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ta5r committed Feb 12, 2025
1 parent c7b4e5c commit 8a7307a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Modules/EnvGenerator/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ protected function prepare_variable( string $name, ?string $value ): ?string {
$env_output = sprintf( '%s=%s', $name, $resolved_value );

// Comment out variables if they're not required and have the default value.
if ( ! $required && $resolved_value === $default ) {
if ( ! $required && $resolved_value === $default && 'NEXT_PUBLIC_URL' !== $name ) {
$env_output = '# ' . $env_output;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Integration/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function testGenerateEnvContent(): void {
NODE_TLS_REJECT_UNAUTHORIZED=5
# The headless frontend domain URL. Uncomment this line and ensure the value matches the URL used by your frontend app.
# NEXT_PUBLIC_URL=http://localhost:3000
NEXT_PUBLIC_URL=http://localhost:3000
# The WordPress "frontend" domain URL
NEXT_PUBLIC_WORDPRESS_URL=https://headless-demo.local
Expand Down Expand Up @@ -130,7 +130,7 @@ public function testDefaultValuesForEnvContent(): void {
# NODE_TLS_REJECT_UNAUTHORIZED=0
# The headless frontend domain URL. Uncomment this line and ensure the value matches the URL used by your frontend app.
# NEXT_PUBLIC_URL=http://localhost:3000
NEXT_PUBLIC_URL=http://localhost:3000
# The WordPress "frontend" domain URL
NEXT_PUBLIC_WORDPRESS_URL=https://headless-demo.local
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/RestControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function testGenerateEnvEndpoint(): void {
$this->assertNotEmpty( $actual_data['content'] );
$search = '\n';
$replace = '';
$expected = "\n# Enable if connecting to a self-signed cert\n# NODE_TLS_REJECT_UNAUTHORIZED=0\n\n# The headless frontend domain URL. Uncomment this line and ensure the value matches the URL used by your frontend app.\n# NEXT_PUBLIC_URL=http://localhost:3000\n\n# The WordPress \"frontend\" domain URL\nNEXT_PUBLIC_WORDPRESS_URL=" . get_home_url() . "\n\n# The WordPress GraphQL endpoint\nNEXT_PUBLIC_GRAPHQL_ENDPOINT=" . graphql_get_endpoint() . "\n\n# The WordPress Uploads directory path\n# NEXT_PUBLIC_WORDPRESS_UPLOADS_PATH=/" . str_replace( ABSPATH, '', wp_get_upload_dir()['basedir'] ) . "\n\n# The WordPress REST URL Prefix\n# NEXT_PUBLIC_WORDPRESS_REST_URL_PREFIX=/" . rest_get_url_prefix() . "\n\n# Token used for authenticating GraphQL introspection queries\nINTROSPECTION_TOKEN=" . IntrospectionToken::get_token();
$expected = "\n# Enable if connecting to a self-signed cert\n# NODE_TLS_REJECT_UNAUTHORIZED=0\n\n# The headless frontend domain URL. Uncomment this line and ensure the value matches the URL used by your frontend app.\nNEXT_PUBLIC_URL=http://localhost:3000\n\n# The WordPress \"frontend\" domain URL\nNEXT_PUBLIC_WORDPRESS_URL=" . get_home_url() . "\n\n# The WordPress GraphQL endpoint\nNEXT_PUBLIC_GRAPHQL_ENDPOINT=" . graphql_get_endpoint() . "\n\n# The WordPress Uploads directory path\n# NEXT_PUBLIC_WORDPRESS_UPLOADS_PATH=/" . str_replace( ABSPATH, '', wp_get_upload_dir()['basedir'] ) . "\n\n# The WordPress REST URL Prefix\n# NEXT_PUBLIC_WORDPRESS_REST_URL_PREFIX=/" . rest_get_url_prefix() . "\n\n# Token used for authenticating GraphQL introspection queries\nINTROSPECTION_TOKEN=" . IntrospectionToken::get_token();

$this->assertEquals( $expected, str_replace( $search, $replace, $actual_data['content'] ) );

Expand Down

0 comments on commit 8a7307a

Please sign in to comment.